派生类的析构函数

版权声明:小简原创 https://blog.csdn.net/qq_43469554/article/details/87444742
#include<iostream>
using namespace std;
class Clock
{
private:
    int H;
    int M;
    int S;
public:
    Clock()
    {
        cout<<"Clock's Constructor Called!"<<endl;
    }
    ~Clock()
    {
        cout<<"Clock's Destructor Called!"<<endl;
    }
  
};
  
class AlarmClock:public Clock
{
private:
    int AH;
    int AM;
public:
    AlarmClock()
    {
        cout<<"AlarmClock's Constructor Called!"<<endl;
    }
    ~AlarmClock()
    {
        cout<<"AlarmClock's Destructor Called!"<<endl;
    }
  
};
  
int main()
{
    AlarmClock A;
  
    return 0;
}

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_43469554/article/details/87444742