Swiss Frank
Swiss Frank

Reputation: 2422

Constructors can only be inherited DIRECTLY from the base?

I have a base class A, that defines some constructors.

Then I have classes B1, B2, B3 that inherit from A.

None of these are meant to be instantiated. Instead, I have classes C11, C12, C13 inheriting from B1, and so on.

C11, C12 etc. all need A's constructors.

I don't think I can write using A::A; in class C11, for instance, right?

The only way to get these constructors (other than cutting and pasting them) is for B1 to say using A::A; and C11 to say using B1::B1;?

Note my question isn't about what a particular compiler supports, but what the spec allows, so "just test it" isn't really an answer to this particular question.

Upvotes: 0

Views: 122

Answers (1)

Igor Tandetnik
Igor Tandetnik

Reputation: 52471

If you are looking for a quote from the standard, then here goes:

[namespace.udecl]/3 ... If a using-declarator names a constructor, its nested-name-specifier shall name a direct base class of the class being defined.

Upvotes: 2

Related Questions