记录codeblock的坑,暂时不用了...

同样的代码:

test.h:

#ifndef TEST_H
#define TEST_H

#include <iostream>

using namespace std;

class Employee
{
public:
    Employee();
    virtual ~Employee();
};

class Singer : public Employee
{
public:
    Singer();
    ~Singer();
};


#endif // TEST_H

test.cpp:

#include "test.h"


Employee::Employee()
{
    cout << "Employee::Employee()" << endl;
}

Employee::~Employee()
{
    cout << "Employee::~Employee()" << endl;
}

Singer::Singer()
{
    cout << "Singer::Singer()" << endl;
}

Singer::~Singer()
{
    cout << "Singer::~Singer()" << endl;
}

main.cpp:

#include <iostream>

#include "test.h"

using namespace std;

int main()
{
    cout << "Hello world!" << endl;

    Employee *pe = new Singer;

    delete pe;

    return 0;
}

上面的例子用来验证:当用父类指针指向子类对象,删除父类指针时,析构函数的执行顺序的;

codeblock直接把:~Singer()函数给吃了...

指不定后面又遇到什么坑,暂时不用了...

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值