what is the code for making an array of objects?

i would greatly appreiciate any replies thank you.

Recommended Answers

All 4 Replies

Hi,
That should be fairly simple. e.g. if you have a class MyClass and you want to make say 5 object array , declare some thing like
MyClass objs[5] ;
If you want a dynamic array use pointers --
MyClass *obj ;
obj = new MyClass[num] ;

Mail me if you have any further doubts .

Isn't it more instructive to discuss things on this message board?

when you want arrays, 99% of the time you actually want a std::vector

Yes, but given the nearly unlimited uses for arrays/vectors, 1% of the time is still a lot...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.