🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: C++ Classes and Objects: all 10 questions

Quiz: C++ Classes and Objects · Question 10 of 10

A setter returns this by reference. What does this make possible?

A setter returns *this by reference. What does this make possible?

  1. A.Making the object constant
  2. B.Chaining calls, such as acc.setName("Asha").setBalance(500)
  3. C.Copying the object automatically
  4. D.Calling the destructor early
Answer & explanation

Correct answer: Chaining calls, such as acc.setName("Asha").setBalance(500)

Each call returns the same object, so the next call can be made on it directly.

Can you get the rest right without peeking?

Take the timed Quiz: C++ Classes and Objects quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →