June 2008
Intermediate to advanced
784 pages
20h 36m
English
Constructors and destructors in a base class are not inherited in the derived class. A derived class has a base portion and a derived portion. The base constructor initializes the base portion, and the constructor of the derived class initializes the derived portion. For the derived object, the default constructor of the base class is called by default to initialize the state of the base class. If the base class does not have a default constructor, a compiler error occurs unless the derived class calls a constructor in the base class that has parameters. In the following code, ZClass does not have a default constructor. A compiler error will occur:
public class ZClass { public ZClass(int param) { } } public class YClass ...Read now
Unlock full access