example5_binding_rvalues_to_lvalue_references.cpp

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

void print(const int& x) {
    std::cout << "Value: " << x << std::endl;
}

int main() {
    print(10);  // 10 is an rvalue, but can be bound to 'const int&'

    return 0;
}
Back to rvalue