Hi, I'm new to C++ and OO programming and I have a question about this code:
How is this allowed obj.foo()=4;?? I know that foo2 returns reference to obj object, but I don't understand how foo works...Code:#include <iostream> using namespace std; class A{ private: int a; int b; public: A(int aa=0,int bb=0){a=aa;b=bb;} int geta(){return a;} int getb(){return b;} A foo(){return *this;} A& foo2(){return *this;} }; int main(){ A obj; obj.foo()=4; return 0; }