Re: If default constructor is not there and parameterized constructor is there, will it work ??

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Ya.. thanks for that..

"Arnaud Debaene" <adebaene@xxxxxxxxxxxxxxxx> wrote in message
news:OqUy0YXWFHA.2796@xxxxxxxxxxxxxxxxxxxxxxx
> Jigar Mehta wrote:
> > Hi,
> > the point i wanted to make was it does not run successfully when we
> > derive the class and base class does not have default constructor..
> Of course it does! You just need to supply the correct base class
> constructor call in the derived class initialization list !
>
> class Base
> {
> public :
> Base (int param) {};
> };
>
> class Derived : public Base
> {
> public :
> Derived() : Base(5) {}; //works
> Derived (int param2) : Base (param2) {}; //works too
> };
>
> Arnaud
> MVP - VC
>
>


.



Relevant Pages