Topic / 110 questions

C++ MCQs

Page 4 of C++ multiple-choice questions with answers. Tap an option to check yourself.

Page 4 of 6

Question 62 C++

Two C++ functions have the same name and the same parameter list but different return types. What happens?

Correct answer B. Compilation fails because functions cannot be overloaded on return type alone

Open question
Advertisement
Question 65 C++

Why should a base class intended for polymorphic use have a virtual destructor?

Correct answer A. So that deleting a derived object through a base pointer runs the derived destructor

Open question
Advertisement
Question 75 C++

Is the declaration const int& r = 5; valid in C++?

Correct answer B. Yes; a temporary is created and its lifetime is extended to match r

Open question
Advertisement