123
来源:互联网 发布:白城广逸网络具体位置 编辑:程序博客网 时间:2024/06/05 15:13
#include <iostream>using namespace std;class Person{public: void sleep() {cout << "sleep" << endl;} void eat() {cout << "eat" << endl;}};
class Author : public Person //Author继承自Person{public: void writeBook() {cout << "write Book" << endl;}};class Programmer : public Person //Programmer继承自Person{public: void writeCode() {cout << "write Code" << endl;}};
class Programmer_Author : public Programmer, public Author //多重继承{};
int main(){ Programmer_Author pa; pa.writeBook(); //调用基类Author的方法 pa.writeCode(); //调用基类Programmer的方法 pa.eat(); //编译错误,eat()定义不明确 pa.sleep(); //编译错误,sleep()定义不明确 return 0;}
阅读全文
0 0
- 123
- 123
- 123
- 123
- 123
- 123
- 123
- 123
- 123
- 123
- 123
- 123
- 123
- 123
- 123
- 123
- 123
- 123
- 程序员必备之沟通的艺术
- leetcode 219. Contains Duplicate II 217. Contains Duplicate
- 【Java基础18_1】Map集合
- 顺序队列和链队列的实现(实验3.2)
- 基于注解开发项目中spring.xml文件的配置
- 123
- nmap端口扫描及邮件告警脚本
- 短除法求最大公约数(转自算法设计与分析第三版)
- 用类描述计算机中CPU的速度和硬盘的容量,要求Java应用程序有4个类,名字分别为:pc CPU harddisk 和Test ,其中TEST是主类。
- 前端面试题系列(1):doctype作用 标准模式与兼容模式
- 从零开始开发IoC依赖注入框架 -- containerx (深入研究Spring源码)
- Java 练习把一个文件从一个地方剪切到另一个地方
- java基础练习----21点(游戏)
- 宝宝购物网站前端设计(一)div + css 布局技术