arrays - How do you delete variables in c++? -


how delete variables in c++ program? have simple int list[10]; , want delete , change int list[9]. use vectors, still want know how it

if have declared this:

int list[10]; 

there no way "delete" it. either global variable, statically allocated storage, or local variable storage on stack.

i don't know trying accomplish, maybe figure out:

int *list = new int[10];  // allocate new array of 10 ints delete [] list;           // deallocate array list = new int[9];        // allocate new array 9 ints 

as suggest in question, better off using std::vector, std::list, , rather using raw c-style arrays.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -