高等继续教育 / 面向对象程序设计
题型描述: 简答题
给出下面程序输出结果。
#include
class Base {
private: int Y;
public:
Base(int y=0) {Y=y;cout<<"Base("< ~Base() {cout<<"~Base()\n";}
void print() {cout < class Derived:public Base
{private: int Z;
public:
Derived (int y, int z):Base(y)
{ Z=z;
cout<<"Derived("< ~Derived() {cout<<"~Derived()\n";}
void print() {Base::print(); cout< };
void main()
{Derived d(10,20);
d.print(); }
给出下面程序输出结果。
#include
class Base {
private: int Y;
public:
Base(int y=0) {Y=y;cout<<"Base("<
void print() {cout <
{private: int Z;
public:
Derived (int y, int z):Base(y)
{ Z=z;
cout<<"Derived("<
void print() {Base::print(); cout<
void main()
{Derived d(10,20);
d.print(); }
参考答案:
佳题速递: