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