ForEveR
ForEveR

Reputation: 55887

Implicit copy constructor

Quote from n3337 12.3.1/3

A non-explicit copy/move constructor (12.8) is a converting constructor. An implicitly-declared copy/move constructor is not an explicit constructor; it may be called for implicit type conversions.

Quote from ANSI ISO IEC 14882 2003

A non-explicit copy-constructor (12.8) is a converting constructor. An implicitly-declared copy constructor is not an explicit constructor; it may be called for implicit type conversions.

I have no ideas, how copy-constructor can be used for implicit type conversions. And if it's misprint/error in standard, why it's not corrected since C++03 standard? Any links and examples (if we can use it for type conversions) are really appreciated.

Upvotes: 7

Views: 1689

Answers (2)

essarmaan
essarmaan

Reputation: 1

In implict inlining the inline member function is defined within the class definition.the keyword inline is not used

Upvotes: 0

Mike Seymour
Mike Seymour

Reputation: 254431

A copy constructor can convert from an object of a derived type by slicing it:

struct A {};
struct B : A {};

B b;
A a = b; // uses A::A(A const&) to convert B to A

Upvotes: 9

Related Questions