上一页 1 ··· 81 82 83 84 85 86 87 88 89 ··· 91 下一页
摘要: #include#include#includeusing namespace std;/* 4.6.3 继承中的对象模型*/class Base{public: int a;protected: int b;private: int ... 阅读全文
posted @ 2021-03-17 09:58 yub4by 阅读(22) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;/* 4.6.2 继承方式 公共继承 保护继承 私有继承*/class Base{public: int a;prot... 阅读全文
posted @ 2021-03-17 09:57 yub4by 阅读(20) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;/* 4.6 继承 4.6.1 继承的基本语法 继承优点:减少重复代码 语法: class 子类 :继承方式 父类{} ... 阅读全文
posted @ 2021-03-17 09:56 yub4by 阅读(29) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;/* 4.5.6 函数调用运算符重载 函数调用运算符()也可以重载 由于重载后使用的方式很像函数的调用,故也称为仿函数 仿函... 阅读全文
posted @ 2021-03-17 09:50 yub4by 阅读(43) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;/* 4.5.5 关系运算符重载 可以让连个自定义类型的对象进行对比操作*/class Person{public: string name; ... 阅读全文
posted @ 2021-03-16 19:41 yub4by 阅读(21) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;/* 4.5.4 赋值运算符重载 C++编译器至少给一个类添加4个函数 默认构造函数,无参,函数体为空(4.2.4) ... 阅读全文
posted @ 2021-03-16 19:40 yub4by 阅读(33) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;/* 4.5.3 递增运算符重载 可通过此实现自己的整型数据 分两种:前置、后置 总结: 前置递增返回引用,后置递增返回值*/cla... 阅读全文
posted @ 2021-03-16 19:39 yub4by 阅读(63) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;/* 4.5.2 左移运算符重载 可以输出自定义的数据类型*/class Person{public: int a; int b; /... 阅读全文
posted @ 2021-03-16 17:58 yub4by 阅读(41) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;/* 4.5 运算符重载 对已有运算符重新进行定义,赋予其另一种功能,以适应不同的数据类型 4.5.1 加号运算符重载 实现两个自定义... 阅读全文
posted @ 2021-03-16 17:56 yub4by 阅读(45) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;/* 4.4.3 成员函数做友元*/class Building;class Goodgay{public: Goodgay(); // 构造声明 voi... 阅读全文
posted @ 2021-03-16 14:49 yub4by 阅读(39) 评论(0) 推荐(0)
上一页 1 ··· 81 82 83 84 85 86 87 88 89 ··· 91 下一页