I am answering this based specifically on C++ programming, as I am not certain which OOP language you are using, but I expect that the principles, if not the specific syntax, will apply.
When you define a class with at least one constructor, the compiler will not generate an implicit constructor. As such, if the constructor(s) you define for the base class require parameters, they must be included in a specific call from the constructor in the child class since there will be no parameter free constructor to call.
class Parent
{
public:
Parent(int a,int a)
:a(a),
b(b)
{
cout<<"Parent constructor "<<a<<b;
}
~Parent()
{}
private:
int a;
int b;
};
class Child : public Parent
{
public:
Child()
:c(5) //error: implicit constructor for Parent is not found
{
cout<<"Child constructor "<<c;
}
~Child()
{}
private:
int c;
};
int main()
{
Child x;
return 0;
}
This problem can be corrected by including a call to the Parent constructor within the constructor for the Child class as follows:
.
.
.
Child()
:Parent(3,4), // Explicit call to Parent constructor
c(5)
{
cout<<"Child constructor "<<c;
}
.
.
.
Hope this helps.