| johnhoffman (25) | |||||
I am teaching myself the basics of inheritance with the code snippet below.
As you see, the Square class inherits properties from the Polygon class. However, I am getting the following compilation errors.
Why is the default constructor for Polygon being called? I thought that I had explicitly called a custom constructor for Polygon in the constructor for Square. | |||||
|
Last edited on
|
|||||
| Fransje (238) | |||
In the constructor of a derived class you should call the constructor of the base class in the initialization list, which looks like this:
Explanation: http://www.cprogramming.com/tutorial/initialization-lists-c++.html | |||
|
Last edited on
|
|||