Answer Posted / ashish
An object is a contiguous region of memory storage. An
lvalue (pronounced: L value) is an expression that refers to
such an object. The original definition of lvalue referred
to "an object that can appear on the left-hand side of an
assignment." However, const objects are lvalues, and yet
they cannot appear on the left-hand side of an assignment.
An expression that can appear in the right-hand side of an
expression (but not in the left-hand side of an expression)
is an rvalue. For example:
#include <string>
using namespace std;
int& f();
void func()
{
int n;
char buf[3];
n = 5; // n is an lvalue; 5 is an rvalue
buf[0] = 'a'; //buf[0] is an lvalue, 'a' is an rvalue
string s1 = "a", s2 = "b", s3 = "c"; // "a", "b", "c" are
rvalues
s1 = // lvalue
s2 +s3; //s2 and s3 are lvalues that are implicitly
converted to rvalues
s1 =
string("z"); // temporaries are rvalues
int * p = new int; // p is an lvalue; 'new int' is an
rvalue
f() = 0; // a function call that returns a reference is
an lvalue
s1.size(); // otherwise, a function call is an rvalue
expression
}
An lvalue can appear in a context that requires an rvalue;
in this case, the lvalue is implicitly converted to an
rvalue. An rvalue cannot be converted to an lvalue.
Therefore, it is possible to use every lvalue expression in
the example as an rvalue, but not vice versa.
| Is This Answer Correct ? | 3 Yes | 1 No |
Post New Answer View All Answers
How do you write a program which produces its own source code as output?
please explain every phase in the "SDLC" in the dotnet.
What is the difference between class and object in c?
How will you divide two numbers in a MACRO?
What are examples of structures?
How can I do serial ("comm") port I/O?
What is mean by Data Driven framework in QTP? Can any one answer me in details on this regard.
What is static identifier?
How many types of sorting are there in c?
How does placing some code lines between the comment symbol help in debugging the code?
Is file a keyword in c?
What is typedef?
which of the following is not a character constant a) 'thank you' b) 'enter values of p, n ,r' c) '23.56E-o3' d) all of the above
List a few unconditional control statement in c.
List some applications of c programming language?