I'm having trouble working on my data structure programming project!!
I have to implement the statistician class but the operator overloading part is a problem!!
 ``123456789101112131415161718192021222324252627282930313233`` ``````#include namespace main_savitch_2C { class statistician { public: // CONSTRUCTOR statistician( ); // MODIFICATION MEMBER FUNCTIONS void next(double r); void reset( ); // CONSTANT MEMBER FUNCTIONS int length( ) const; double sum( ) const; double mean( ) const; double minimum( ) const; double maximum( ) const; // FRIEND FUNCTIONS friend statistician operator + (const statistician& s1, const statistician& s2); friend statistician operator * (double scale, const statistician& s); private: int count; // How many numbers in the sequence double total; // The sum of all the numbers in the sequence double tinyest; // The smallest number in the sequence double largest; // The largest number in the sequence }; // NON-MEMBER functions for the statistician class bool operator ==(const statistician& s1, const statistician& s2); }``````
 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364`` ``````#include #include "stats.h" using std::cout; using std::cin; using std::endl; namespace main_savitch_2C{ statistician::statistician(){ count = 0; total = 0; } void statistician::next(double r){ if(count ==0){ tinyest = r; largest = r; } else if(count != 0){ if(r < tinyest){ tinyest = r; } else if(r > largest){ largest = r; } } total += r; count++; } int statistician::length() const{ return count; } double statistician::sum() const{ return total; } double statistician::mean() const{ return (total/count); } double statistician::minimum() const{ return tinyest; } double statistician::maximum() const{ return largest; } statistician statistician::operator + (const statistician& s1, const statistician& s2){ statistician result; result.total = s1.total + s2.total; result.count = s1.count + s2.count; if(s1.tinyest <= s2.tinyest){ result.tinyest = s1.tinyest; } else { result.tinyest = s2.tinyest; } if(s1.largest >= s2.largest){ result.largest = s1.largest; } else { result.largest = s2.largest; } return result; } }``````