vector

S

Simply_Red

Hi.


if i have a table of vector:

std::vector<Points>* ArraySol = new std::vector<Points>[nbValues];


to free the memory do i have to do:

for (int i = 0; i<nbValues;i++) ArraySol.clear();
delete[] ArraySol ;


or delete[] ArraySol is enought??
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

Hi.


if i have a table of vector:

std::vector<Points>* ArraySol = new std::vector<Points>[nbValues];


to free the memory do i have to do:

for (int i = 0; i<nbValues;i++) ArraySol.clear();
delete[] ArraySol ;


or delete[] ArraySol is enought??


delete[] is enough. Preferably though, you would use a vector or vectors
instead of dynamically allocating an array of vectors.
 
S

Simply_Red

if i have a table of vector:
std::vector<Points>* ArraySol = new std::vector<Points>[nbValues];
to free the memory do i have to do:
for (int i = 0; i<nbValues;i++) ArraySol.clear();
delete[] ArraySol ;

or delete[] ArraySol is enought??

delete[] is enough. Preferably though, you would use a vector or vectors
instead of dynamically allocating an array of vectors.


thanks
 
H

HuangWei

It`s engouh. However, it is a good haibit to let a unuseful pointer points a
null.

just like Arraysol = NULL;
 
J

Juha Nieminen

Simply_Red said:
std::vector<Points>* ArraySol = new std::vector<Points>[nbValues];

What's wrong with
std::vector<std::vector<Points> > ArraySol(nbValues); ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top