You are here:

C++/lValue required

Advertisement


Question
What is lValue? Some of the C++ programs I have written, have flagged an error 'lValue required". So what is lValue?

Any help would be appreciated.

Answer
Hello Binoy, thank you for the question.

I have often wondered why they choose this word and not something more descriptive myself. You normally see that error when you try and do something like modify a constant. Here is an example:

int foo(const int x)
{
x += 5;
return x;
}

int main()
{
int g = 5;
foo(g);
}

This will produce the error of "lvalue required".

There are a couple of other things that can cause this error also. I believe if you try to add two pointers it will produce it.

I hope this information is helpful.

- Eddie

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Eddie

Expertise

I can answer questions about the C++ language, object oriented design and architecture. I am knowledgable in a lot of the math that goes into programming, and am certified by ExpertRating.com. I also know a good deal about graphics via OpenGL, and GUIs.

Experience

I have completed numerous games and demos created with the C++ programming language. Currently employed as a software engineer in the modeling and simulation field. I have about 7 years experience.

©2016 About.com. All rights reserved.