-
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?
-
you cant have a variable starting with a number.. you can have a number inside the varible name, but not as the first letter.. :)
-
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?
-
AmonRa beat me to telling myself that i was wrong :D :D
-
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.
-
Well I have created an instance,
Code:
class MyClass {
...
} RCMain;
but i am using the tdo chars in a class function.
-
When using a member variable in a member function, just refer to it either by its name alone, or this-><name goes here>.
Z.