Menu

why dosn't this work

Naytheyus
2006-10-28
2012-09-26
  • Naytheyus

    Naytheyus - 2006-10-28

    i tried using the following

    ex

    struct tNewStruct{
    int a;
    int b;
    int c;
    }NewStruct, *ptrNewStruct;

    NewStruct tTempStruct;
    NewStruct *ptrTempStruct;

    GotoThisCall((ptrTempStruct)&tTempStruct) <-invalid operands to binary &

    void GotoThisCall(ptrNewStruct NewStruct)
    {
    ....;
    }

    in all the book i have on C use this example (in they're own way) but why am i getting this error
    do i need to set something or add a lib to the compiler?

    books C for Dummies
    Teach Yourself C
    & some on-line docs

    thanx for any help

     
    • Malciah

      Malciah - 2007-04-27

      Umm, not sure if I'll be any help here, as I've been learning C++, but I do have a question for you:

      Maybe it changed in C++, or maybe I'm looking at it wrong, but your structure's name is: tNewStruct
      and you made an object to it called: NewStruct.

      Now, under your structure, it looks like you are using the object to make another object, and a pointer:

      NewStruct tTempStruct;
      NewStruct *ptrTempStruct;

      Now, if that's indeed what you are doing, then shouldn't it be:

      tNewStruct tTempStruct;
      tNewStruct *ptrTempStruct;

      You make objects to your class, not other objects.

      If this helps... Hooray!

      If not, sorry... I tried sniff :( ( lol )

      Good luck,

      -Malciah

       

Log in to post a comment.