Hi guys!
I don't know anything about how to use operator+(), I have just searched some sites(tutorial / articles) and have done what they have said, but didn't succeeded in compiling my program.
Here is the code, (commenting the lines used for operator+())
Compiler says that, there is no operator+ for 'obj2 + 10'Code:#include <iostream> using namespace std; class math { private: int number; public: math(); //constructor of the class // math operator+(math); math::math() { number = 0; } int main() { math obj1, obj2; // int a = 10; // obj1 = obj2 +a; obj1 = obj2 + 10; } math math::operator+(math obj) //Also wrote (math obj, int x) and many other combinations { math temp; temp.number = obj.number + 10; return (temp); }



LinkBack URL
About LinkBacks



