void Add()
{
x + y = answer;
std::cout <<x <<" plus "<< y <<" equals "<< answer"\n";
}
weird error
This is a simple problem yet it evades me =(
and the errors
non-lvalue in assignment
expected `;' before string constant
Thanks in advance.
LValue = left side value. These are variables you can change.
RValue = right side value. These are variables that you can read.
x + y = answer
It doesn't know how to set (x + y) to anything... thus, it says its not an L-value.
Also, make sure x and y are somewhere in your code. If that is the entire function, x and y must be globals. I'm guessing that you have them somewhere, or it would complain that it doesn't know what x and y are.
So to fix your problem:
answer = x + y;
oh... and in your cout... at the very end you need to change
answer"\n";
to
answer << "\n";
or
answer << std::endl;
RValue = right side value. These are variables that you can read.
x + y = answer
It doesn't know how to set (x + y) to anything... thus, it says its not an L-value.
Also, make sure x and y are somewhere in your code. If that is the entire function, x and y must be globals. I'm guessing that you have them somewhere, or it would complain that it doesn't know what x and y are.
So to fix your problem:
answer = x + y;
oh... and in your cout... at the very end you need to change
answer"\n";
to
answer << "\n";
or
answer << std::endl;
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement