您的位置:首页 > 其它

第十/十一周训练1-5

2016-05-03 15:12 169 查看
#include <iostream>

using namespace std;

class A

{

protected:

int a,b;

public:

A(int aa, int bb):a(aa), b(bb) {}

void printA(){

cout<<"a: "<<a<<"\tb: "<<b<<endl;

}

};

class B: public A

{

int c;

public:

B(int aa, int bb, int cc):A(aa,bb),c(cc) {}

void printB()

{

cout<<"a: "<<a<<"\tb: "<<b<<"\tc: "<<c<<endl;

}

};

int main()

{

A a(1,1);

B b(2,3,4);

a=b;

a.printA();

b.printA();

b.printB();

return 0;

}

猜想:2,3 2,3 2,3,4

实际:正确
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: