Sorry for two questions in succession.
I would like to declare a vector of an Object as instance data then initialize its size in a constructor, as such:
class Test
{
private:
std::vector<Object_I_madeup> myVector;
int n;
public:
Test(int n):
n(n)
{
myVector(n); //Intending to set the size of the vector to n entries
}
I tried to find a .setSize() a la Java, and doubt I should use resize(). I know this isa simple question - but what is the best way to do this?
Thanks
Testclass? Vectors already store their size so if your class has it too you are just storing the same thing twice.nin your case). That tends to lead to hard to track down bugs in my experiencesize_and a function namedsize()to retrieve the value in a user-friendly way.