C++ Output Prediction Medium +20 XP
Reference vs Copy
What is the output?
C++Read-only
int a = 5; int& b = a; b = 10; cout << a;
What is the output?
Show answer and explanation
Answer: 10
b is a reference to a. Changing b also changes a because they share the same memory.
Hint: References are aliases.
What this challenge tests
Output Prediction in C++: references, memory.