Utilizzo di eliminazione

Esistono due varianti sintattiche per operatore delete: una per i singoli oggetti e l'altro per le matrici di oggetti.Nel codice seguente viene illustrato come questi sono diversi:

// expre_Using_delete.cpp
struct UDType 
{
};

int main()
{
   // Allocate a user-defined object, UDObject, and an object
   //  of type double on the free store using the
   //  new operator.
   UDType *UDObject = new UDType;
   double *dObject = new double;
   // Delete the two objects.
   delete UDObject;
   delete dObject; 
   // Allocate an array of user-defined objects on the
   // free store using the new operator.
   UDType (*UDArr)[7] = new UDType[5][7];
   // Use the array syntax to delete the array of objects.
   delete [] UDArr;
}

I due risultati non definiti i prodotti di casi: tramite il form di matrice di eliminazione (delete []) su un oggetto e sull'utilizzo del form nonarray delete in una matrice.

Vedere anche

Riferimenti

Espressioni con gli operatori unari