主题如以下:
正确改动后的程序:
#include <iostream.h> //using namespace std; class BASE { char c; public: BASE(char n):c(n){} virtual~BASE() {cout<<c;} }; class DERIVED:public BASE { char c; public: DERIVED(char n):BASE(n+1),c(n){} ~DERIVED(){cout<<c;} }; int main() { DERIVED('X'); cout<<endl; return 0; }
执行结果:
版权声明:本文博主原创文章。博客,未经同意不得转载。