If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

I will quote the exact text present in the site from where I took the above code :

Code:

The object bar is constructed in two stages: first, the Foo constructor is invoked and then the Bar constructor is invoked. The output of the above program will be to indicate that Foo's constructor is called first, followed by Bar's constructor.

Now, my question is:

Will the constructor Foo() be called when an object of class Bar is declared?

Re: Inheritance of base class constructor?

It will be called, but it is not, strictly speaking, inherited.

If the constructor were inherited, then it would be possible to call only Foo's constructor somehow. It isn't; the Foo constructor can only be called as part of the Bar constructor call from Bar's point of view.

Re: Inheritance of base class constructor?

It is true that the base class constructors are not inherited. However, there is a base class subobject, and a base class constructor must be invoked to construct that. Since you did not specify the base class constructor to use in the initialisation list, the default constructor of the base class is invoked.