标签:
#include<iostream> using namespace std; class Byte{ public: Byte(){b=0;} Byte(int k){b=k;} const Byte operator+(const Byte& right)const{ return Byte(b+right.b); } const Byte operator-(const Byte& right)const{ return Byte(b-right.b); } const Byte operator*(const Byte& right)const{ return Byte(b*right.b); } Byte& operator+=(const Byte& right){ b+=right.b; return *this; } bool operator ==(const Byte& right)const{ return b==right.b; } int getnum(){ return b; } private: int b; }; int main(){ Byte test(3),k(3),haha; if(test==k) cout<<"true"<<endl;
Byte test(3),k(2),haha;
test+=k;
cout<<test.getnum()<endl;
return 0; }
标签:
原文地址:http://www.cnblogs.com/test404/p/5524509.html