How does the global operator work with class data? What are his qualities, and how does he differ from friend?
class Demo { private: double d; public: Demo() { d = 0.0; } Demo(double x) { d = x; } ~Demo() { cout <<"In Destructor" << endl; } double getd() { d = 5; return d; } }; bool operator<(Demo a, Demo b) { return a.getd() < b.getd(); } bool operator==(Demo a, Demo b) { return a.getd() == b.getd(); } int main() { Demo o1(2.0),o2(3.0); if(o1<o2) cout << "True"; cout << endl; return 0; }