In C++ I understand that (++i) should return a reference to i because the need of concatenation of operators, but what I can’t figure out is:
Why (i++) should return i by value?
Can anyone please clarify.
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.
++ican be written asSince the real
iis returned, we can take reference of it. However,i++looks likeas
old_thisis just a local variable, the reference of it is pointless afteri++is completed. So logically it should return an rvalue.