#include <iostream>using namespace std;class Per{friend const Per operator/(const Per &p,const Per &p1);private:int id;int score;public:Per() {}Per(int id,int s):id(id),score(s){}const Per operator-(const Per &p) const{Per temp;temp.id=id-p.id;temp.score=score-p.score;return temp;}void show(){cout << "id= " << id << " " << "score= " << score << endl;}};const Per operator/(const Per &p,const Per &p1){Per temp;temp.id=p.id/p1.id;temp.score=p.score/p1.score;return temp;}int main(){Per p(1001,100);Per p1(1000,80);Per p2=p-p1;p2.show();Per p3=p/p1;p3.show();return 0;}
运行: