How to differentiate between overloading the 2 versions of operator ++ ?
const T& operator ++(const T& rhs)
which one?
i++;
++i;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
These operators are unary, i.e., they do not take a right hand side parameter.
As for your question, if you really must overload these operators, for the preincrement use the signature
const T& operator ++(), and for the postincrement,const T& operator(int). The int parameter is a dummy.