Jump to content
  • Advertisement
Sign in to follow this  

weird error

This topic is 4496 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post

Link to post
Share on other sites
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";
answer << std::endl;

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!