Base class constructors are automatically called for you if they have no argument. If you want to call a superclass constructor with an argument, you must use the subclass's constructor initialization list.
// do something with foo
class SubClass : public SuperClass
SubClass(int X, int Y)
: SuperClass(X) // Call the superclass constructor in the subclass' initialization list.
// do something with Y
Answered by: RAJESH HEGDE
Spend a minute to Register
in a few simple steps, for complete access to the Social Learning Platform with Community Learning Features and Learning Resources.
If you are part of the Learning Community already, Login