Computer Science, asked by chaitanyazade1931, 1 year ago

What are Lvalues and Rvalues in C++?

Answers

Answered by NiksDwivedi
0

\huge\bold{Answer}

__________________________________

Lvalue :-

It is something that identifies an object. Lvalue is the variable on the left side of the expression.

Rvalue :-

It is something that assigned to a variable that is on left side. Rvalue is the value on the right hand side of the expression.

Eg:-

&lt;font color=blue&gt;int x; // x is an lvalue&lt;br&gt;</p><p>int* p; // *p is an lvalue&lt;br&gt;</p><p>int a[100]; // a[42] is an lvalue; equivalent to *(a+42)&lt;br&gt;</p><p>// note: a itself is also an lvalue&lt;br&gt;</p><p>struct S { int m; };&lt;br&gt;</p><p>struct S s; // s and s.m are lvalues&lt;br&gt;</p><p>struct S* p2 = &amp;s; // p2-&gt;m is an lvalue; equivalent to (*p2).m&lt;br&gt;</p><p>// note: p2 and *p2 are also lvalues

Hope it helps you

Similar questions