Why is Default constructor called in virtual inheritance?

When using virtual inheritance, the virtual base class’s constructor is called directly by the most derived class’s constructor. In this case, the daughter constructor directly calls the grandmother constructor.

Since you didn’t explicitly call grandmother constructor in the initialization list, the default constructor will be called. To call the correct constructor, change it to:

daugther(int attr) : grandmother(attr), mother(attr) { ... }

See also This FAQ entry.

Leave a Comment