By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,778 Members | 1,947 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,778 IT Pros & Developers. It's quick & easy.

Explicit ctors

P: n/a
Hello all,

I am able to declare as explicit ctors that cannot take exactly one
argument - they either take fewer (default ctor) or more arguments. What is
the significance of declaring such ctors explicit?

Speaking specifically of default ctors, I find the following in the
12.3.1/2: "A default constructor may be an explicit constructor; such a
constructor will be used to perform default-initialization (8.5)."

Unfortunately, this doesn't help clarify the situation for me with regard to
default ctors, and, of course, it doesn't speak at all to ctors that must
take more than one argument.

Why would one ever want to designate a copy ctor as being explicit?

The purpose of explicit ctors is to inhibit implicit conversions. How does
that come into play when dealing with copy ctors? How would you ever have
an "implicit conversion" to the class type of which you already are?

Designating a copy ctor as explicit seems to inhibit only the following:

a. Variable definitions such as: foo_t a = b; (Note that "foo_t a(b);" is
b. Returning an object by value; (Note that *passing* it by value seems to
be OK however.)

Jul 22 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.