Results 1 to 7 of 7

Thread: Strange Errors...

  1. #1

    Thread Starter
    Addicted Member Virtual24's Avatar
    Join Date
    May 2001
    Posts
    228

    Strange Errors...

    I have defined a struct like so:
    Code:
    struct z3D_OBJECT {
        HINSTANCE hDll;
        char *FlNm;
    };
    then i tried to set some variables as my struct:
    Code:
    z3D_OBJECT 3doMain;
    z3D_OBJECT *3doObjs;
    ...those are in a class header... I am getting 3 strange errors when compiling the file:

    Syntax Error: 'bad sufix on number'
    Syntax Error: 'constant'
    unexpected token(s) preceeding ';'

    I get those same three errors for each time I declare a variable of type, z3D_OBJECT.

    Does any1 know whats wrong?
    To protect time is to protect everything...

  2. #2
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500
    you cant have a variable starting with a number.. you can have a number inside the varible name, but not as the first letter..
    Amon Ra
    The Power of Learning.

  3. #3

    Thread Starter
    Addicted Member Virtual24's Avatar
    Join Date
    May 2001
    Posts
    228
    Okay, I Oughta hit myself... The error was obviously because i was trying to put a number as the first character in a variable name which is illeagal... duh!

    So i fixed that and brought my error count from 102 to 38... so there is a new error i have a question on:
    now when i try to say
    Code:
    MyClass::tdoChars = new z3D_OBJECT;
    i get an error saying "syntax error: missing ')' before ';'"
    does anyone know the answer to that one?? I should be able to have public variables declared in classes right?
    To protect time is to protect everything...

  4. #4

    Thread Starter
    Addicted Member Virtual24's Avatar
    Join Date
    May 2001
    Posts
    228
    AmonRa beat me to telling myself that i was wrong
    To protect time is to protect everything...

  5. #5
    Zaei
    Guest
    MyClass::tdoChars is only legal if tdoChars is defined as static in the class:
    Code:
    class MyClass {
    public:
      static z3D_OBJECT* tdoChars;
      ...
    };
    Otherwise, you have to create an instance of the class, and use the dot or arrow operators.

    Z.

    [edit]
    I cannot type.

  6. #6

    Thread Starter
    Addicted Member Virtual24's Avatar
    Join Date
    May 2001
    Posts
    228
    Well I have created an instance,
    Code:
    class MyClass {
        ...
    } RCMain;
    but i am using the tdo chars in a class function.
    To protect time is to protect everything...

  7. #7
    Zaei
    Guest
    When using a member variable in a member function, just refer to it either by its name alone, or this-><name goes here>.

    Z.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width