题目如下:
正确修改后的程序:
#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; }
运行结果:
CSDN 夏令营程序 试题分析
时间: 2024-12-28 13:15:16