🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.vector<int> v
  2. B.const vector<int> &v
  3. C.vector<int> *v always
  4. 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 →