CJCoding With Joseph
15free / daySign inCreate account
← Back to Question List

Select topics to narrow your question pool, then enable Random to jump to a random question matching your filters.

Topics:
C++ Quiz #125

Which identify Overload Runs

mediumTemplates

Two overloads of identify exist: one takes T&, the other takes T&&. What is printed?

📄 Code

1#include <iostream>
2 
3template <typename T>
4void identify(T&) {
5 std::cout << "Lvalue\n";
6}
7 
8template <typename T>
9void identify(T&&) {
10 std::cout << "Rvalue\n";
11}
12 
13int main() {
14 int x = 1;
15 identify(x);
16 identify(5);
17 identify(x + 1);
18 return 0;
19}