#include
#include
#include
using namespace std;
class c1
{
public:
c1() {
cout << "c1 构造函数" << endl;
}
virtual void function() = 0;
virtual ~c1() {
cout << "c1 析构函数" << endl;
}
};
class c2:public c1
{
public:
c2() {
cout << "c2 构造函数" << endl;
}
void function()
{
cout << "我是c2" << endl;
}
virtual ~c2() {
cout << "c2 析构函数" << endl;
}
};
class c3:public c2
{
public:
c3(){
cout << "c3 构造函数" << endl;
}
//void function()
//{
// cout << "我是c3" << endl;
//}
virtual ~c3(){
cout << "c3 析构函数" << endl;
}
};
int main(void)
{
cout << "构造函数" << endl;
cout << "***********************" << endl;
c1 *p = new c3;
cout << "调用的函数" << endl;
p->function();
cout << endl;
cout << "析构函数" << endl;
delete[] p;
system("pause");
return 0;
}