You are here:



3 questions related to a program I am writing:
1) Is it necessary that a derived class have a ctor? If yes or no, explain please.
2)Is it necessary that a base clase haev a ctor?
3)is it mandatory for a derived class ctor to call a base class ctor if one exists?

sid , Thank you for your question.

1. No, classes need not have ctors. If a class has no class member variables, or if it has them but they need not be initialized, there may be no need for a ctor. Ctors are for the programmer's convenience; there is nothing about program structure that should require them.

2. No, classes need not have ctors.

3. C++ guarantees that the base class ctor, if any, is called when a derived class is instantiated. No explicit ctor function call or initialization item is needed. An exception is when the base ctor requires an argument list. Then an explicit ctor function initialization item is needed in the derived ctor initialization list.

David Spector


All Answers

Answers by Expert:

Ask Experts


David Spector


Highly knowledgeable in the C++ language, Visual C++ (MSVC), Windows API, documentation and other quality-assurance techniques, and debugging. Knowledgeable in MFC, COM, GUI design, and object-oriented design.


I have been a software engineer since 1965. I have been published. My specializations have been: biomedical programming, compiler implementation, and many kinds of Windows programming. I don't do Databases or other business-oriented stuff.

Windows?/DOS Developer's Journal, ACM SIGPLAN Notices, and Computer Science Press.

ICCP Systems Programming Certification
Master's degree equivalent in Computer Science

©2017 All rights reserved.