|
-
Mar 28th, 2002, 10:50 PM
#1
Thread Starter
Addicted Member
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...
-
Mar 29th, 2002, 12:59 AM
#2
Hyperactive Member
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.
-
Mar 29th, 2002, 01:01 AM
#3
Thread Starter
Addicted Member
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...
-
Mar 29th, 2002, 01:02 AM
#4
Thread Starter
Addicted Member
AmonRa beat me to telling myself that i was wrong
To protect time is to protect everything...
-
Mar 29th, 2002, 01:14 AM
#5
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.
-
Mar 29th, 2002, 08:01 AM
#6
Thread Starter
Addicted Member
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...
-
Mar 29th, 2002, 11:29 AM
#7
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|