struct TestOne {
int X;
int Y;
};
struct TestTwo {
TestOne OBJ;
int Z;
};
TestTwo ITEM;
ITEM.OBJ.X = 1;
error occours at the last line. "expected constructor, destructor, or type conversion before '.' token."
I've never used nested structs in C++ before, and all the reference sites I look at list examples similar to this one, even for DevC++ specifically.
It has been a while since I've progged C++, I've been picking it back up now for a few months (mainly working w/ irrlicht)
Yes it was placed outside main().
What's the difference?
I want a global variable of a nested structure...
Not sure why DevC++ don't like it
PS - sticking it in main() worked, but how can I make it global then?
Or should i just define it globally, and alter it within main() or other functions?
Ok, hang on,
I tried my said idea above ^ (define globally, modify from within functions)
and all is working well so far...
Now just for the file loader...
Thanks for the help btw guys,
I'm working on a simple but effective camera scripting engine to plugin to my games. So far, so good. It runs if I manually code a script, but I'm going to add a loadFromFile function.
Thanks!
Provided that your struct is an aggregate, you s/could initialize your global instance using the aggregate initializer syntax. There are some advantages to doing this over adding a constructor as proposed above.