I am interested to know if an object can be deleted using the destructor method?
The constructor and destructor of my class:
class cal { public: cal() { days = 0; day = 1; month = 1; year = 1300; leap = true; }; ~cal() { delete this; } }*calendar = new cal;
How can I remove this pointer through a class?
PS
I forgot to write the following code
cal *calandar = new cal[];
I want to use it on a heap not a stack
I want to often use this class (objects) (many of this object), imagine how long I have to write delete, and it makes a deep understanding, troubleshooting, and tracking codes. I want them to be automatically destroyed (on the heap)
I used the following code in my class, when I execute "delete [] calendar", it reduces the number of rams used (the number of bars used), does it work correctly (destroy all objects), leaving the program? Since I use GNU / Linus and it destroys all objects with or without these lines, I am worried about a leak in windows
void DisposeObject() { delete this; }
Mostafajf
source share