Classes: Inheriting constructors

Syntax

Functionality

  • If the using-declaration refers to a constructor of a base class (e.g. using Base::Base;), constructors of that base class are inherited.
  • The inherited constructors are equivalent to user-defined constructors with an empty body and with a member initializer list consisting of a single nested-name-specifier, which forwards all of its arguments to the base class constructor.

 

Quiz – is the following code valid?

Answer: Yes, we inherited constructors with 0 and 1 parameters from the base class.

 

You may also like...

Leave a Reply