#include <iostream>#include <math.h>using namespace std;class Score{private: float c;public: Score(){c=0;} Score(float a) { c=a; } float get_s() { return c; } Score operator+ (Score &c1); Score operator/ (int &c1);}; Score Score::operator+(Score &c1) { Score c2; c2.c=c+c1.c; return c2; } Score Score::operator /(int &c1) { Score c2; c2.c=c/c1; return c2; }int main()
{ Score Math(80),Chinese(75),English(85); Score total= Math+Chinese+English; Score average = total/3; std::cout<<total.get_s()<<std::endl; std::cout<<average.get_s()<<std::endl; return 0;
}
{ Score Math(80),Chinese(75),English(85); Score total= Math+Chinese+English; Score average = total/3; std::cout<<total.get_s()<<std::endl; std::cout<<average.get_s()<<std::endl; return 0;
}