|
-
Aug 31st, 2002, 10:25 PM
#1
Thread Starter
Addicted Member
Error w/ 'struct' using Dev-C++
Hi,
I have added a structure to my code. I tried initializing variables and kept getting an error citing a syntax error before '.'
Here is a code fragment...
Code:
struct gameObject
{
float x; //current position
float y;
float z;
};
gameObject cam;
cam.x=0;
The error points to line that reads cam.x=0;
Any clues? Do I need a specific header?
Regards,
ChuckB
-
Aug 31st, 2002, 10:34 PM
#2
Frenzied Member
Hmm, odd. Try this:
Code:
struct gameObject cam;
cam.x = 0;
That is C style structure variable declaration.
Z.
-
Sep 2nd, 2002, 12:33 AM
#3
Thread Starter
Addicted Member
Thanks for writing Z,
The structure was correct. However, C++ doesn't like 'cam.x=0;' to go above all of the functions. I placed the initialization inside a initVars() function and it worked well...learning curve. :-)
In fact, I got rid of the structure and made my first official C++ class CGameObject with about a dozen variables and a dozen functions to manage my robots on the game field.
Regards,
ChuckB
-
Sep 2nd, 2002, 12:53 AM
#4
Frenzied Member
Ah, ok. I hadnt realized that the assignment wasnt in a function =).
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
|