Error question.

J

JoeC

I am trying to write a program and I send a pointer to an object to
another object and I want to get a number out of that object It is
strange this works:

static mapmgt m(b, trn, b->GetSizeX(), b->GetSizeY());

but this doesn't work:

static mapmgt m(b, trn){
xlen = b->GetSizeX();
 
T

Thomas Tutone

JoeC said:
I am trying to write a program and I send a pointer to an object to
another object and I want to get a number out of that object It is
strange this works:

static mapmgt m(b, trn, b->GetSizeX(), b->GetSizeY());

but this doesn't work:

static mapmgt m(b, trn){
xlen = b->GetSizeX();

Why is it strange? Please post the definition of mapmgt, a complete
compilable piece of code that duplicates the error, and the exact error
message you get.

Best regards,

Tom
 
J

JoeC

Thomas said:
Why is it strange? Please post the definition of mapmgt, a complete
compilable piece of code that duplicates the error, and the exact error
message you get.

Best regards,

I am going with the first first function. The program is large and
complex. b is apointer and I can get the numbers that way but if I
send the pointer to the function it said somthing like the some value
is not an int when it is. I am just going with what what works.
 
H

Howard

What doesn't work?

Why do you have "board *" there? I assume you're creating a local static
object of type mapmgt, called m. Correct? In that case, ditch the "board
*" part, and just pass the parameter values.

Perhaps you really meant to do something like this: ?

// in some function...
{
...
int xlen = b->GetSizeX();
int ylen = b->GetSizeY();
static mapmgt m(b, trn, xlen, ylen);
....
}

In which case, if you don't xlen and ylen elsewhere, why bother? Your first
example is fine.
I am going with the first first function. The program is large and
complex. b is apointer and I can get the numbers that way but if I
send the pointer to the function it said somthing like the some value
is not an int when it is. I am just going with what what works.

That's fine, but in the future, if you want help, you'll need to post code
that's real, even if you change the names and even if you can only post a
few lines actually related to the error. Also, post the actual text of the
error message, not "it said somthing like the some value is not an int when
it is".

-Howard
 
J

JoeC

Howard said:
What doesn't work?


Why do you have "board *" there? I assume you're creating a local static
object of type mapmgt, called m. Correct? In that case, ditch the "board
*" part, and just pass the parameter values.


Perhaps you really meant to do something like this: ?

// in some function...
{
...
int xlen = b->GetSizeX();
int ylen = b->GetSizeY();
static mapmgt m(b, trn, xlen, ylen);
...
}

In which case, if you don't xlen and ylen elsewhere, why bother? Your first
example is fine.


That's fine, but in the future, if you want help, you'll need to post code
that's real, even if you change the names and even if you can only post a
few lines actually related to the error. Also, post the actual text of the
error message, not "it said somthing like the some value is not an int when
it is".

-Howard

OK, thanks. some times it can be dificult to post revelent lines of
code from a complex program. I do have another question which I will
start another topic.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top