高等继续教育 / 面向对象程序设计
正确率:100%
#include <iostream>
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”);
return 0;
}
执行上面的程序将输出()
A、Y
B、X
C、XY
D、YX
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”);
return 0;
}
执行上面的程序将输出()
A、Y
B、X
C、XY
D、YX
参考答案:
佳题速递: