I am new to c++. When I try to compile the code below , I get this error
constructor for \'child\' must explicitly initialize the base class \'parent\' whic
The parent class has an explicit constructor, so compiler will not add an implicit 'empty' constructor to it. Additionally your constructor has a parameter, so compiler can not generate an implicit call to it. That's why you must do it explicitly.
This way:
child::child(int a) : parent(a) { }