make a vector of an objects c++ code example
Example: make a vector of an objects c++
#include
using std::vector;
class MyClass { .... };
vector myVector( 100, MyClass() );
/* myVector now contains 100 objects of type MyClass, built with the default constructor */
vector myVector2;
// MyVector2 is empty
myVector2.assign( 100, MyClass() );
// My Vector2 now contains 100 objects of type MyClass, built with default ctor