example2_lvalues_assignment.cpp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#include <iostream>

int main() {
    int a = 5;
    int b = 10;

    a = b;  // 'a' and 'b' are both lvalues
    b = 20; // You can assign to an lvalue

    std::cout << "a: " << a << std::endl;
    std::cout << "b: " << b << std::endl;

    return 0;
}
Back to lvalue