Blackteahamburger
Blackteahamburger

Reputation: 215

Why base class copy and move constructors should not be inherited?

CWG2356:

Base class copy and move constructors brought into a derived class via a using-declaration should not be considered by overload resolution when constructing a derived class object.

But other constructors that are inherited from the base class only initializes the base class subobject, too.

So, why base class copy and move constructors should not be inherited?

Upvotes: 0

Views: 97

Answers (1)

Dave S
Dave S

Reputation: 21113

Keep in mind, the default implementations of the copy/move constructors of the derived class already call the base class copy/move constructors. If the base class copy and move constructors were eligible for overload resolution, you would make the following legal, which in general is not desirable:

Base b;
Derived d = b;

Upvotes: 1

Related Questions