简介
其实没什么好介绍的,完整版看这里https://blog.csdn.net/algorithmyyds/article/details/122153488
代码
#include <bits/stdc++.h>
using namespace std;
class point
{
private:
int score;
string name;
public:
point():score(0),name(""){}
point(int s):score(s),name(""){}
point(string n):score(0),name(n){}
point(int s,string n):score(s),name(n){}
int GetScore()
{
return score;
}
string GetName()
{
return name;
}
void SetScore(int s)
{
score=s;
}
void SetName(string n)
{
name=n;
}
int operator+(point& p)
{
return score+p.score;
}
int operator-(point& p)
{
return max(score,p.score)-min(score,p.score);
}
};
int main()
{
point p(0,"po");
point po(2);
cout<<p+po<<endl;
return 0;
}