+ 1
Why two time base / parent constructor is not called
Hi Refer below code: https://code.sololearn.com/cX9l5GI7RLSu/?ref=app Even if we don't deligate call to first constructor, base constructor is always called... Then why two times base constructor is not getting called...?
1 ответ
+ 1
Ketan Lalcheta
In C++ (OOP) concept whenever you create an object of class it calls constructor explicitly or implicitly.
Here when derived class C object is created as
class C is derived from
class P. It tries to create
class C code is calling
class P is created by explicitly by initialiser P(x).
So it will call explicitly base class constructor and then enters into derived class constructor.
because base class constructor is called explicitly it will not call implicitly.
That's why base class constructor is called only once.