代码整理, 将学过的三种运算符重载,每个至少实现一个运算符的重载:分别是-,-=,<。
#include
using namespace std;
class Stu
{
friend const Stu operator-(const Stu &L,const Stu &R);
friend bool operator<(const Stu &L,const Stu &R);
friend Stu &operator-=(Stu &L,const Stu &R);
private:
int a;
int b;
public:
Stu(){}
Stu(int a,int b):a(a),b(b)
{}
// const Stu operator-(const Stu &R)const //算数成员函数-=
// {
// Stu temp;
// temp.a=a-R.a;
// temp.b=b-R.b;
// return temp;
// }
//--------------------------------------------------------------------------------------------------
// bool operator<(const Stu &R)
// {
// if (a