c++ error C2105: '++' needs l-value
Hello,
First let me say that this is homework and I am asking for a general understanding of the probem as much if not more than I am asking for an answer.
I have a question that asks what is wrong with the following statement? Provide the code to accomplish what the user intended.
cout << ++( x + y );
I put the code in the compiler and I get the error "error C2105: '++' needs l-value". From the above code should I assume that someone is trying to display the value of x+y+1 or is this maybe some part of a loop? I am sure this is an easy questions but the book I have has let me to no real answer.
Secondly, I have a simple program that takes user input and does some basic calculations. Although it is not required at this point in the class I would like to validate the users data so that entering unexpected characters does not cause an error. At this time the program just assumes that the user will enter an integer. How would I go about verifying that a number is an integer? I know how to validate input in perl, but this seems different. Pointing me to a tutorial or a good source of online learning would be greatly appreciated.
Thanks,
Shawn
|