“Know how to solve every problem that has been solved.” “What I cannot create, I do not understand.” — Richard Feynman

Value categories: what can you point at?

Learn

Lesson 1 of 7 standard ~5 min

Every expression in C++ has a value category. The textbook taxonomy (lvalue, prvalue, xvalue) sounds abstract, but there is one operational test that cuts through it: can you take the address of the result? If &expr is legal, the expression is an lvalue — it names a durable object with storage. If not, it is an rvalue — a value with no address you can hold onto.

int x = 5;

x        // lvalue  — &x is fine, x has storage
5        // prvalue — &5 is nonsense, it is just a value
x + 1    // prvalue — the + makes a temporary, no address
Three expressions, two categories.

Start with the discrimination itself. Which of these names something you could point at?

introMultiple choice

In int x = 5; int& r = x;, which expression below is an lvalue?

Go deeper ↓Pointers in C++

Now feel the consequence. The address-of operator is not just a test for lvalue-ness — it is the test, enforced by the compiler.

standardPredict + reveal

Does this compile? If not, why? Predict before revealing.

int a = 3, b = 4;
int* p = &(a + b);
std::cout << *p;
Go deeper ↓Pointers in C++

That distinction is the whole reason move semantics exists: an rvalue is a temporary about to die, so it is safe to steal from. The next skill builds directly on this.