I have a vector
std::vector<Cla ssA*> a_vector;
I need to be able to hold a bunch of ClassA objects in it. I understand it is better to push adress of ClassA objects than the object itself. But i still end up with a bad_alloc since there are about 100,000 of them i need to hold in the vector.
So my question is how can i malloc some space to a_vector based on the size of ClassA Address?
I know this is wrong but , how do i correct the following
ClassA* dummy = new ClassA();int maxEntries = 100000;
std::vector<Cla ssA*> a_vector = (std::vector<Cl assA>*)malloc(m axEntries*sizeo f(dummy));
delete dummy;
Thank You
std::vector<Cla ssA*> a_vector;
I need to be able to hold a bunch of ClassA objects in it. I understand it is better to push adress of ClassA objects than the object itself. But i still end up with a bad_alloc since there are about 100,000 of them i need to hold in the vector.
So my question is how can i malloc some space to a_vector based on the size of ClassA Address?
I know this is wrong but , how do i correct the following
ClassA* dummy = new ClassA();int maxEntries = 100000;
std::vector<Cla ssA*> a_vector = (std::vector<Cl assA>*)malloc(m axEntries*sizeo f(dummy));
delete dummy;
Thank You
Comment