How do I call the class's destructor?
I have a simple C++ code, but I don't know how to use the destructor: class date { public: int day; date(int m) { day =m; } ~date(){ cout << "I wish you have entered the year \n" << day; } }; int main() { date ob2(12); ob2.~date(); cout << ob2.day; return 0; } The question that I have is, what should I write in my destructor code, that after calling the destructor, it will delete the day variable ? Marius You should not call your destructor explicitly. When you create your object on the stack (like you did) all you need is: int main() { date ob2(12); // ob2.day holds 12 return 0; // ob2's