Question 4
Back to Exercise
Given void inc(int& x);, which call is valid?
- A inc(5);
- B int n = 5; inc(n); Correct
- C inc(n + 1);
- D inc(5.0);
Correct Answer: Option B
A non-const lvalue reference binds only to a modifiable variable. Literals and expression results are temporaries; they bind to const int& but not int&.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!