May 2012
Intermediate to advanced
679 pages
16h 56m
English
It is important to note that the constructors are not inherited in the inheritance process, unlike other members which are inherited. Syntax of derived class constructor is special. The reason is this constructor not only initializes its own data members but also those of the base class. For this, it has to allot arguments for base class constructor too. In prototype, constructor looks normal, but in definition, it has a peculiar syntax. Let us first see a simple program.
Program: Write a program to define a class clock. It should be derived from class time. The program should demonstrate the calling of constructors clearly.
Solution: See Program 9.4.
// constru1.cpp ...
Read now
Unlock full access