example3_lvalue_references.cpp

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

void modify(int& ref) {
    ref += 10;  // Modify the lvalue reference
}

int main() {
    int value = 30;
    modify(value);  // Pass 'value' as an lvalue reference

    std::cout << "Modified value: " << value << std::endl;

    return 0;
}
Back to lvalue