← Quiz: References and Functions: all 10 questions
Quiz: References and Functions · Question 3 of 10
How should a function receive a large vector it only reads?
How should a function receive a large vector it only reads?
- A.vector<int> v
- B.const vector<int> &v
- C.vector<int> *v always
- D.It's not possible
Answer & explanation
Correct answer: const vector<int> &v
const reference avoids a copy and prevents changes.
Can you get the rest right without peeking?
Take the timed Quiz: References and Functions quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →