c++中多重继承
来源:互联网 发布:mysql 1064 syntax 编辑:程序博客网 时间:2024/06/05 16:24
// multiple inheritance#include <iostream>using namespace std;class Polygon { protected: int width, height; public: Polygon (int a, int b) : width(a), height(b) {}};class Output { public: static void print (int i);};void Output::print (int i) { cout << i << '\n';}class Rectangle: public Polygon, public Output { public: Rectangle (int a, int b) : Polygon(a,b) {} int area () { return width*height; }};class Triangle: public Polygon, public Output { public: Triangle (int a, int b) : Polygon(a,b) {} int area () { return width*height/2; }};int main () { Rectangle rect (4,5); Triangle trgl (4,5); rect.print (rect.area()); Triangle::print (trgl.area()); return 0;}
阅读全文
0 0
- (C++)多重继承
- C++--多重继承
- C#中多重继承
- C#中多重继承
- C#中多重继承
- c++中多重继承
- C++-继承:多重继承 && 虚拟继承
- C++【多重继承和虚继承】
- 多重继承中函数同名
- 多重继承中函数同名
- Java中实现多重继承
- Java中类不能多重继承,接口可以多重继承
- C++】多重继承,救世主还是鸡肋
- 解决多重继承中函数同名方案
- C#中接口多重继承的注意事项
- C#中接口多重继承的注意事项
- C#中接口多重继承的注意事项
- C#中接口多重继承的注意事项
- 导出excel
- C++ 数组(1)
- HTTP请求错误状态码大全
- Android应用在更新版本时的出现的问题
- GDAL分块处理流程
- c++中多重继承
- 好东西来了!2017云栖大会400+份重磅资料下载
- JavaScript中的作用域(链)和闭包(一)
- RxJava2系列实践之倒计时功能(三)
- 根据Map的value值进行排序
- 不换行结尾用其他符号代替css写法
- 详解自动售货机设计原理方案
- How to set splash timeout in scrapy-splash?
- log4j自动发送错误日志邮件