So I have a class (HostObject) that has a vector of complex classes (object1) inside it. Such as the pseudocode depicted below
#DEFINE ARRAY_SIZE 10
class HostOb
There is no constructor for std::vector
for for reserving capacity. The only way you can reserve capacity is to use reserve
member function.
#DEFINE ARRAY_SIZE 10
class HostObject {
//other member variables
vector vec;
//default constructor
HostObject(){
vec.reserve(ARRAY_SIZE);
}
//my custom constructor
HostObject(double parmeter1, double parameter2, doubleparameter3) {
vec.reserve(ARRAY_SIZE);
//some code doing some calculations
for (int i = 0; i
Read more about std::vector