C++03 3.10/1 says: “Every expression is either an lvalue or an rvalue.” It’s important to remember that lvalueness versus rvalueness is a property of expressions, not of objects.
Lvalues name objects that persist beyond a single expression. For example, obj
, *ptr
, ptr[index]
, and ++x
are all lvalues.
Rvalues are temporaries that evaporate at the end of the full-expression in which they live (“at the semicolon”). For example, 1729
, x + y
, std::string("meow")
, and x++
are all rvalues.
The address-of operator requires that its “operand shall be an lvalue”. if we could take the address of one expression, the expression is an lvalue, otherwise it’s an rvalue.
&obj; // valid &12; //invalid
Related Posts:
- What are the differences between a pointer variable and a reference variable in C++?
- What does `*&` in a function declaration mean?
- initial value of reference to non-const must be an lvalue
- Reference to non-static member function must be called
- C++ pass an array by reference
- Is C++ Array passed by reference or by pointer?
- Linker Error C++ “undefined reference ” [duplicate]
- Return array in a function
- What does “dereferencing” a pointer mean?
- Regular cast vs. static_cast vs. dynamic_cast
- What is a smart pointer and when should I use one?
- What does “dereferencing” a pointer mean?
- What is a char*?
- What exactly is nullptr?
- Are the C++ & and * operators inverses in all contexts?
- c++ “Incomplete type not allowed” error accessing class reference information (Circular dependency with forward declaration)
- How to fix a “invalid operands to binary expression” error?
- What is a dangling pointer?
- (->) arrow operator and (.) dot operator , class pointer
- Pass a vector by reference C++
- What is uintptr_t data type
- What is the difference between const int*, const int * const, and int const *?
- how does the ampersand(&) sign work in c++?
- C++ – No matching member function for call to ‘push_back’
- What is uintptr_t data type
- What does int & mean
- What is the difference between const int*, const int * const, and int const *?
- Difference between const reference and normal parameter
- Pointer to incomplete class type is not allowed
- Passing a 2D array to a C++ function
- Is the practice of returning a C++ reference variable evil?
- Can’t resolve Error: indirection requires pointer operand (‘int’ invalid)
- When should I use the new keyword in C++?
- How to create a dynamically-allocated array of const objects, but have values assigned to them?
- How to access the contents of a vector from a pointer to the vector in C++?
- How to make an array with a dynamic size? General usage of dynamic arrays (maybe pointers too)?
- What does int & mean
- C++: Expression must have a constant value when declaring array inside function
- Sorting Linked List C++ with pointers
- Delete 2D array C++
- Is the sizeof(some pointer) always equal to four?
- C++ Expression must have pointer-to-object type
- C++ strings and pointers
- Typedef function pointer?
- How to initialize a vector of pointers
- What is the use of intptr_t?
- Error: No instance of constructor matches the argument list
- c++ “Incomplete type not allowed” error accessing class reference information (Circular dependency with forward declaration)
- C++ – Assigning null to a std::string
- Using C-string gives Warning: “Address of stack memory associated with local variable returned”
- Why use pointers?
- C++ Return value, reference, const reference
- What’s the difference between * and & in C?
- How to create a vector of class objects in C++?
- Function stoi not declared
- C++ Array of pointers: delete or delete []?
- Why should I use a pointer rather than the object itself?
- Function stoi not declared
- C++ correct way to return pointer to array from function
- Warning: comparison of distinct pointer types
- Is null reference possible?
- Initializing pointers in C++
- Why can’t I make a vector of references?
- Difference between function arguments declared with & and * in C++
- Difference between the int * i and int** i
- set head to NULL (‘NULL’ : undeclared identifier)
- What is a `char*`?
- clearing a vector of pointers [duplicate]
- C++ Swapping Pointers
- Meaning of *& and **& in C++
- Array of Linked Lists C++
- Differences between unique_ptr and shared_ptr
- How to create a dynamic array of integers
- How to implement 2D vector array?
- What is the difference between g++ and gcc?
- What is the best way to use a HashMap in C++?
- How do I convert a double into a string in C++?
- How to create timer events using C++ 11?
- How to concatenate two strings in C++?
- ‘g++’ is not recognized as an internal or external command, operable program or batch file
- Read file line by line using ifstream in C++
- Virtual/pure virtual explained
- error: redefinition of class
- terminate called after throwing an instance of ‘std::invalid_argument’ what(): stoi
- Destructor for a linked List
- Why use a new call with a C++ ‘vector’?
- class not declared in scope – even though .h was included
- Best C/C++ Network Library
- How to check that an element is in a std::set?
- Best way to extract a subvector from a vector?
- How does rhs work?
- error: expected unqualified-id before ‘.’ token //(struct)
- Base class undefined
- What does ** mean in C?
- GCC -fPIC option
- function does not take 1 arguments c++
- overloaded function with no contextual type information
- How exactly do lookup tables work and how to implement them?
- Vector declaration “expected parameter declarator”
- “Incomplete type not allowed ” when creating std::ofstream objects