Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

peter86

left operand must be l-value?

This topic is 5712 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

I get this compile error: left operand must be l-value when i run this code: objDesc.wszFileName = wszPath; Both var''s are WCHAR''s. What´s l-value and what´s wrong?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Is objDesc the name of the object or its class?

If its the name of the class it would be like trying to assign a type a value:

_ int = 100;
_ float = 100.53; // etc...

You just can''t do that.

Share this post


Link to post
Share on other sites
quote:
Original post by peter86
What´s l-value


The terminology is something of a carry over from the earliest days of C. The "L" stands for "left" as in left operand and there is also a corresponding "R" value - as in "right"

left = right

A "L-value" is a value into which another value can be assigned. For example a variable of some kind. As in the AP''s example

int = 0 - this won''t work because there''s no variable there to store the value - there''s only a type, but no space - there''s no there there.

int x = 0 - this works just fine because there''s a there there to store the value in

An "R" value is a value that can be stored in an "L" value - pretty much what is typically thought of as a ''value'' - a literal or a result returned by a function.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Could be a problem with it being private too.

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
Could be a problem with it being private too.



I looked it up and it isn´t.

Share this post


Link to post
Share on other sites
if you created a class called objDesc with this member: wszFileName thats just fine.

But you have to create an object from that class to assign data too.

objDesc MyObject;

// this is legal
_ MyObject.wszFileName = whatever; // Only if member is a pointer and not an array

// Sorry no variable to assign data to no L-value
_ objDesc.wszFileName = whatever;

** remember you can't use a class name as an object **



[edited by - CodeJunkie on October 5, 2002 4:47:47 AM]

Share this post


Link to post
Share on other sites
Ignore the insane comment above.

You can''t assign anything to a C array, period.

  
int main ()
{
int array[10];
array = anyTypeInTheWorldYouCanThinkOf; // error

}

Arrays are not legal lvalues. Jan''s answer was correct.

HTTP 500 retry #1..

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!