how could i get and set data on an array of objects? cant find a tutorial anywhere
Oct 6, 2012 at 9:50am UTC
so im looking into what this is...
class classname [6] is this an array of class objects?
if i wrote class classname [3] is that classname object number three or something else?
Oct 6, 2012 at 9:55am UTC
You would have gotten compilation errors.
Something like this should work.
1 2 3 4 5 6
class Classname
{
........
};
Classname Grade1[4];
This is declaring an array of type
Classname , with four elements.
For more info:
http://cplusplus.com/doc/tutorial/ **This is the link to the full tut.
Hope it helps,
Aceix.
Last edited on Oct 6, 2012 at 9:56am UTC
Oct 6, 2012 at 9:58am UTC
No, that's an array of 6 forward declarations of "
classname ", which isn't valid C++. A declaration of an array takes this form:
ClassName array_name[6]; // 6 "ClassName" objects.
Accessing the array takes this form:
The sub-script index is base-0, meaning that the index of the first element is 0, and the last is the array's
length - 1. An index is an offset from the first element that identifies different elements within the array.
Wazzak
Topic archived. No new replies allowed.