C++ 运算符重载

C++ 运算符重载
 1 #include <iostream>
 2 using namespace std;
 3 
 4 class Good
 5 {
 6 public:
 7     int member;
 8     Good(int a): member(a)
 9     {
10         cout << "调用构造" << endl;
11     }
12     void show()
13     {
14         cout << member << endl;
15     }
16     Good operator+(const Good& obj)
17     {
18         return Good(member - obj.member);
19     }
20 };
21 
22 int main(int argc, char *argv[])
23 {
24     Good a(10), b(20);
25     Good c = a + b;
26     c.show();
27     return 0;
28 }
C++ 运算符重载

C++ 运算符重载,布布扣,bubuko.com

C++ 运算符重载

上一篇:PHP实现多图片上传


下一篇:javascript中this的用法----个人见解