Copy constructor hides default constructor

A

Aire

Will defining a copy constructor also make the default constructor not
available anymore, until a default constructor is explicitly provided?
Thanks!
 
J

Jumbo

Aire said:
Will defining a copy constructor also make the default constructor not
available anymore, until a default constructor is explicitly provided?
Thanks!

Yes I think it does.
If you provide a copy constructor then you'll need to provide a default
constructor.

Be carefull when using the phrase 'constructor explicitly provided' as this
could be confused with a 'constructor using the explicit keyword'.
 
J

John Harrison

Aire said:
Will defining a copy constructor also make the default constructor not
available anymore, until a default constructor is explicitly provided?
Thanks!

Yes, implicit default constructor only generated if no other constructors
are defined. This is for compatibility with C struct's.

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top