Loading

摘要: 1.加号运算符重载 #include <iostream> using namespace std; #include <string> // 加号运算符重载 // 实现两个自定义数据类型的相加运算 // 1.通过成员函数 2.通过全局函数 class Person{ public: // 1.通过 阅读全文
posted @ 2022-01-17 19:33 少年人永远倔强 阅读(103) 评论(0) 推荐(0) 编辑
摘要: 1.全局函数作友元 #include <iostream> using namespace std; #include <string> // 友元: 让一个函数或类 访问另一个类的私有成员 class Building{ // 友元声明 friend void GoodGay1(Building 阅读全文
posted @ 2022-01-17 19:29 少年人永远倔强 阅读(47) 评论(0) 推荐(0) 编辑
摘要: 1.成员变量和成员函数分开存储 #include <iostream> using namespace std; // 空类的对象 size 为1 class NullClass{ }; class Person{ int m_A; // 非静态成员变量 属于类的对象上 }; class All{ 阅读全文
posted @ 2022-01-17 19:26 少年人永远倔强 阅读(21) 评论(0) 推荐(0) 编辑