Home > Back-end > C rear overloaded with flow insertion operator overloading using an error at the same time
C rear overloaded with flow insertion operator overloading using an error at the same time
Time:10-27
//the code below #include using namespace std; The class Per { Int m_A; Public: Per (int num) { M_A=num; } //overload & lt; Friend ostream& Operator<(ostream& Out, Per& P) { The out & lt; <"M_A=" & lt; Return the out; } //rear overloaded + + Per operator++ (int) { Per temp=* this; This - & gt; M_A + +; Return temp. } }; Int main () { Per p (10); cout p++; cout //cout & lt; return 0; } //why the second at the same time use & lt;
CodePudding user response:
Friend ostream& Operator<(ostream& Out, Per& P) in Per& Per instead, P++ not an lvalue