top of page

Lvalues and Rvalues

  • Writer: -A
    -A
  • Jan 28, 2020
  • 1 min read

There are two kinds of expressions in C++ −

lvalue − Expressions that refer to a memory location is called "lvalue" expression. An lvalue may appear as either the left-hand or right-hand side of an assignment.

rvalue − The term rvalue refers to a data value that is stored at some address in memory. An rvalue is an expression that cannot have a value assigned to it which means an rvalue may appear on the right- but not left-hand side of an assignment.

Variables are lvalues and so may appear on the left-hand side of an assignment. Numeric literals are rvalues and so may not be assigned and can not appear on the left-hand side. Following is a valid statement −

int g = 20;

But the following is not a valid statement and would generate compile-time error −

10 = 20;

Comments


Post: Blog2_Post

Subscribe Form

Thanks for submitting!

  • Instagram
  • Facebook

©2020 by C++ Programming. Proudly created with Wix.com

bottom of page