[code=cpp]class Base
{ public:
Base(){}
/*Base(int x)
{
int a=x;
//int b=y;
cout<<"b="<<a<< endl;
//cout<<"y="<<b<< endl;
}*/
};
class der: public Base
{ public:
der(int x)//:Base(x)
{
int a=x;cout<<"x="< <a<<endl;
}
};
void main()
{
der d(1);
getch();
}
[/code]
In above program if we dont use the default constructor then we have to use explicit calling of constructor.
Why it is required......
{ public:
Base(){}
/*Base(int x)
{
int a=x;
//int b=y;
cout<<"b="<<a<< endl;
//cout<<"y="<<b<< endl;
}*/
};
class der: public Base
{ public:
der(int x)//:Base(x)
{
int a=x;cout<<"x="< <a<<endl;
}
};
void main()
{
der d(1);
getch();
}
[/code]
In above program if we dont use the default constructor then we have to use explicit calling of constructor.
Why it is required......
Comment