I want to make a dynamic array of class objects. Though it is dynamic I have to calculate some size before initiating them; what strategy should I apply?
+10
A:
Use the std::vector class from the standard library. That implements a strongly-typed dynamic array. It can be found inside the header <vector>.
Konrad Rudolph
2010-04-28 08:43:17
+1: That's *exactly* the right thing to do.
Donal Fellows
2010-04-28 08:45:45
can it store my custom data type defined in class?
shak
2010-04-28 08:55:30
@shak: Use `std::vector<my_class>` to store objects of your class.
sbi
2010-04-28 09:00:40