第十/十一周训练1-6
2016-05-03 15:12
218 查看
#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);
b=a;
a.printA();
b.printA();
b.printB();
return 0;
}
//a缺少一个值,无法替换
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);
b=a;
a.printA();
b.printA();
b.printB();
return 0;
}
//a缺少一个值,无法替换
相关文章推荐
- 第十/十一周训练1-5
- MongoDB数据库设计中6条重要的经验法则,part 3
- CDH HBase Indexer的基本使用
- SiteView
- 背景渐变,兼容所有手机端
- webapi单元测试时出现的ConfigurationManager.ConnectionStrings为空错误
- SDL按钮制作
- 关于MySQL的几点安全配置
- 第十/十一周训练1-4
- 第十一周 阅读程序(5e)
- InnoDB dictionary
- Node和Element的区别
- POJ 3581 Sequence(后缀数组)
- MongoDB数据库设计中6条重要的经验法则,part 2
- web项目配置404页面和500页面
- Android自定义View
- 含有蓝牙功能的App上线AppStore被拒的原因
- Android通过反射获取build.prop中key对应的value
- SDWebImage使用方法
- 用因果图分析微博经验值规则生成测试用例