Site Tools


delete
удаление объекта по указателю

Мудрость гласит: любой new сопровождается delete -)

int* ptrInt = new int(3); // объект int
delete ptrInt;

int* ptrInt = new int[3]; // массив int
delete[] ptrInt;
MyClass *obj = new MyClass();
delete obj;
удаление двумерного массива
for (int i = 0; i<n; i++)
      delete [] a[i];
delete [] a;
Удаление трехмерного массива
for (i=0; i<M; i++)
      {
      for (j=0; j<N; j++)
              delete []mas[i][j];
      delete []mas[i];
      }
delete []mas;
You could leave a comment if you were logged in.
delete.txt · Last modified: 2013/04/04 22:28 by konovalov

Page Tools