How do I call the class's destructor?

Viewed 90908

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?

7 Answers
Related