Does 'delete [] varname;' delete multiple arrays in C++?

  • Context: C/C++ 
  • Thread starter Thread starter neurocomp2003
  • Start date Start date
  • Tags Tags
    Arrays
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
4 replies · 6K views
neurocomp2003
Messages
1,359
Reaction score
4
Was wondering if the "delete [] varname;" deletes multiple arrays

eg...

I coded a 3-D array as follows:

type ***name;
name = new type**[n];
for i: name= new type*[n];
for i,j: name[j]=new type[n];
and name[j][k] is and element in the array

now does
"delete [] varname;" suffice to delete the 3D array?
or do i have to first delete name[j] then delete name and then name.
 
Physics news on Phys.org
coo, thanks so its

for i,j: delte name[j]
for i: delete name
delete [] name?

oh yeah one other Q, if i allocate memory and forget to deallocate...when the programm shuts down does it autodeallocate for me? or do i have to turn off my system?
 
thanks dduardo...heh i was just using "delete [] name" now i should go correct it. Its fun to watch 1000 3D spherical (billiard) balls colliding eating up the resources, yay for a double for loop...now i got to add in some scene mgmt tech.