CPA-21-02 practice question 33 of 35

What is not inherited from the base class?

Full set: 257 questions
Answer options
A: constructor Correct answer
B: destructor Correct answer
C: operator=() Correct answer
D: operator+()
Correct Answer:
A. constructor; B. destructor; C. operator=()
Explanation

According to the C++ Standard, derived classes inherit all members of the base class with specific exceptions: constructors, destructors, and copy/move assignment operators are not inherited. While C++11 introduced the ability to explicitly inherit constructors via the using declaration, they are not inherited by default. Destructors are never inherited, as each class has its own specific cleanup requirements. Similarly, copy and move assignment operators (operator=) are not inherited because the compiler implicitly declares them for the derived class, which hides the base class versions.

Why Incorrect

D: Incorrect because operator+() (and other general overloaded operators) are standard member functions and are normally inherited by derived classes without issue.

References

1. ISO/IEC 14882:2017 Standard, Section 13.2 [class.derived] paragraph 3 ("Constructors, destructors, and copy assignment operators are not inherited").

2. MIT OpenCourseWare, 6.096 Introduction to C++, Lecture 8 (Inheritance and Polymorphism).

Scroll to Top