标签:
1、阅读下面的程序,并写出运行结果
(2)虚析构函数
#include <iostream> using namespace std; class BASE { private: char c; public: BASE(char n):c(n) {} virtual ~BASE() { cout<<c; } }; class DERIVED:public BASE { private: char c; public: DERIVED(char n):BASE(n+1),c(n) {} ~DERIVED(){ cout<<c; } }; int main(){ DERIVED d('X'); return 0; }
预计运行结果:XY
实际运行结果:
第13周 《C++语言基础》程序阅读——多态性与抽象类 (2)
标签:
原文地址:http://blog.csdn.net/zp___waj/article/details/46042143