上一页 1 ··· 82 83 84 85 86 87 88 89 90 ··· 92 下一页
摘要: #include#include#includeusing namespace std;/* 4.5.3 递增运算符重载 可通过此实现自己的整型数据 分两种:前置、后置 总结: 前置递增返回引用,后置递增返回值*/cla... 阅读全文
posted @ 2021-03-16 19:39 yub4by 阅读(71) 评论(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 阅读(52) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;/* 4.4.3 成员函数做友元*/class Building;class Goodgay{public: Goodgay(); // 构造声明 voi... 阅读全文
posted @ 2021-03-16 14:49 yub4by 阅读(45) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;/* 4.4.2 类做友元*/class Building; // 声明Building类,后续会写,防止Goodgay类中引用时报错class Goodgay{pu... 阅读全文
posted @ 2021-03-16 14:48 yub4by 阅读(50) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;/* 4.4 友元 让一个函数或类可以访问另一个类中的私有成员 关键字friend 三种实现: 全局函... 阅读全文
posted @ 2021-03-16 14:47 yub4by 阅读(68) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;/* 4.3.4 const修饰成员函数 常函数:成员函数后加const(修饰的是this指针,令指针指向的值也不可修改) 常函数... 阅读全文
posted @ 2021-03-16 12:10 yub4by 阅读(31) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;/* 4.3.3 空指针访问成员函数 C++中空指针是可以调用成员函数的 但是注意有没有用到this指针(有坑) 若用到了t... 阅读全文
posted @ 2021-03-16 12:09 yub4by 阅读(46) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;/* 4.3.2 this指针 this指针是隐含每一个非静态成员函数内的一种指针 其不需定义,可直接使用 用途: ... 阅读全文
posted @ 2021-03-15 18:46 yub4by 阅读(22) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;/* 4.3.1 成员变量和成员函数分开存储 C++中,类内的成员变量和成员函数分开存储 只有非静态成员变量才属于类的对象上*/class... 阅读全文
posted @ 2021-03-15 18:46 yub4by 阅读(25) 评论(0) 推荐(0)
上一页 1 ··· 82 83 84 85 86 87 88 89 90 ··· 92 下一页