2021年8月7日
摘要: 1 //函数调用运算符重载 2 3 #include <iostream> 4 #include <string> 5 using namespace std; 6 7 //函数调用运算符重载 8 9 class MyPrint 10 { 11 public: 12 13 //重载函数调用运算符 1 阅读全文
posted @ 2021-08-07 17:45 Bytezero! 阅读(85) 评论(0) 推荐(0) 编辑
摘要: 1 //关系运算符重载 < = > != 2 #include <iostream> 3 #include <string> 4 using namespace std; 5 6 7 //重载关系运算符 8 class Person 9 { 10 public: 11 Person(string n 阅读全文
posted @ 2021-08-07 17:17 Bytezero! 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 1 //赋值运算符重载 = 2 #include <iostream> 3 #include <string> 4 using namespace std; 5 6 //赋值运算符的重载 7 class Person 8 { 9 public: 10 11 Person(int age) 12 { 阅读全文
posted @ 2021-08-07 16:59 Bytezero! 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 #include <string> 3 using namespace std; 4 5 //重载递增运算符 6 7 //自定义整形 8 class MyInteger 9 { 10 friend ostream& operator<<(ostream 阅读全文
posted @ 2021-08-07 16:28 Bytezero! 阅读(77) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 #include <string> 3 using namespace std; 4 5 class Person 6 { 7 friend ostream& operator<<(ostream& cout, Person& p); 8 public 阅读全文
posted @ 2021-08-07 14:34 Bytezero! 阅读(67) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 #include <string> 3 using namespace std; 4 5 //1.成员函数重载 +号 6 class Person 7 { 8 public: 9 10 //Person operator+(Person& p) 11 阅读全文
posted @ 2021-08-07 14:33 Bytezero! 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 1 //友元 全局函数做友元 2 /* 3 #include <iostream> 4 #include <string> 5 using namespace std; 6 7 //建筑物类 8 class Building 9 { 10 11 //GoodGay全局函数 是 Building好朋友 阅读全文
posted @ 2021-08-07 11:32 Bytezero! 阅读(135) 评论(0) 推荐(0) 编辑