+ 1
C++ Destructors
The 'delete' expression doesn't work with objects, right? Only with pointers to objects?
3 Réponses
+ 2
myClass * obj1 = new myClass(6);
...
delete obj1;
+ 2
Correct in the case of objects, delete removes the object from the pointer which takes it out of scope when using dynamically created objects. otherwise the objects naturally remove themselves from memory when they fall out of scope.
+ 1
delete deletes those objects (or variables) for which the memory is dynamically allocated by the operator new. Of course, you can specify this object only with a pointer variable.