-
OOP and global arrays
here is a mock up of what i have:
Code:
struct blah {
// some stuff
};
blah array[100];
...
// functions..
...
this is in a seperate file to the main, [edit] i think [/edit] the compiler asks me to place this decleration inside a function i need it to be global, any ideas? its late where i am so if u need more info or the actual code then ask. Cheers
Code:
28 C:\ass1.cpp variable-size type declared outside of any function
hope this helps
-
Your example says 100, and your error message says "variable-size"
So which is it?
If you need it to be variable, then try
Code:
blah *array;
// then inside some early function
array = new blah[howmany];
-
Yeah sorry should post the code
Code:
static int MAXRECORDS = 100;
struct PetRecord {
// stuff
};
PetRecord PetID[MAXRECORDS];
Hope this helps
more info: this is not inside any function, its in my file ass1.cpp which is before all my functions.
-
Forgot to make it a constant for anyone who cares.
*so angry*