Error question.

Discussion in 'C++' started by JoeC, Sep 18, 2006.

  1. JoeC

    JoeC Guest

    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();
     
    JoeC, Sep 18, 2006
    #1
    1. Advertising

  2. JoeC wrote:

    > 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
     
    Thomas Tutone, Sep 18, 2006
    #2
    1. Advertising

  3. JoeC

    JoeC Guest

    Thomas Tutone wrote:
    > JoeC wrote:
    >
    > > 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(board * b, ....
    > > 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,
    >


    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.
    > Tom
     
    JoeC, Sep 18, 2006
    #3
  4. JoeC

    Howard Guest

    "JoeC" <> wrote in message
    news:...
    >
    > Thomas Tutone wrote:
    >> JoeC wrote:
    >>
    >> > 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:
    >> >


    What doesn't work?

    >> > static mapmgt m(board * b, ....


    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.

    >> > xlen = b->GetSizeX();


    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.

    >>
    >> 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.


    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
     
    Howard, Sep 18, 2006
    #4
  5. JoeC

    JoeC Guest

    Howard wrote:
    > "JoeC" <> wrote in message
    > news:...
    > >
    > > Thomas Tutone wrote:
    > >> JoeC wrote:
    > >>
    > >> > 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:
    > >> >

    >
    > What doesn't work?
    >
    > >> > static mapmgt m(board * b, ....

    >
    > 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.
    >
    > >> > xlen = b->GetSizeX();

    >
    > 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.
    >
    > >>
    > >> 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.

    >
    > 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.
     
    JoeC, Sep 18, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hfk0
    Replies:
    2
    Views:
    21,678
  2. JavaQueries
    Replies:
    1
    Views:
    3,676
    John C. Bollinger
    Mar 1, 2005
  3. Balaji
    Replies:
    3
    Views:
    10,115
  4. Bishop
    Replies:
    1
    Views:
    792
    Bishop
    Feb 24, 2007
  5. juvi
    Replies:
    3
    Views:
    1,054
    Alexey Smirnov
    Jan 22, 2009
Loading...

Share This Page