array of classes

I do not really understand how to implement an array of a class. I have been looking all over and I understand (minimally) about classes. its like a boosted structure and I understand that you can store data inside of it.
it can store data AND it can store functions. I also understand that an array will hold like types of data. What is confusing me is this....
is the array inside of the class or is the class inside of the array?

I think that maybe answering this question will help me to determine how that data is accessed.

I know it may seem to be a stupid question but I tend to overanalyze things and my brain is my own worst enemy.
is the array inside of the class or is the class inside of the array?

That depends on where you have declared the array. If you declare an array in your class definition then it would be inside the class. If you declare an array outside the class then the class is contained within the array.

Remember an array of a class is basically the same as an array of any POD (Plain Old Data) type.

1
2
3
4
5
6
7
8
9
10
class types
{
    public:
        int myArray[10]; // An array of 10 ints contained within the class.
};

...

    types myArray[10]; // An array of 10 types. Each element contains an array of 10 ints.
Last edited on
Topic archived. No new replies allowed.