weird error

Started by
2 comments, last by Unconquerable 17 years, 10 months ago
This is a simple problem yet it evades me =(

void Add()
{
     x + y = answer;
     std::cout <<x <<" plus "<< y <<" equals "<< answer"\n";
}


and the errors non-lvalue in assignment expected `;' before string constant Thanks in advance.
Advertisement
Should it not be answer = x+y;?
-----"Master! Apprentice! Heartborne, 7th Seeker Warrior! Disciple! In me the Wishmaster..." Wishmaster - Nightwish
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;
-------Harmotion - Free 1v1 top-down shooter!Double Jump StudiosBlog
fixed thanks alot =D

This topic is closed to new replies.

Advertisement