Topic: Is this wrong?


Author: "John Hickin" <hickin@nortel.ca>
Date: 1997/09/20
Raw View
I have noticed with some compilers that a definition of the form

 class MyClass {
 public:
   MyClass(int =0);
   MyClass();
 };

isn't immediately flagged as an error (the error comes when you try to invoke
the default constructor).

Does the standard have anything to say about this?

There might actually be a use for this type of thing: a deliberate ambiguity
pre-empts the possibility of using a default constructor, even in the class
code itself (as opposed to the case of client classes, where simply making the
constructor private would suffice).

--
John Hickin      Nortel Technology, Montreal, Quebec
(514) 765-7924   hickin@nortel.ca
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: stephen.clamage_nospam@eng.sun.com (Steve Clamage)
Date: 1997/09/23
Raw View
On 20 Sep 97 00:42:05 GMT, "John Hickin" <hickin@nortel.ca> wrote:

 >I have noticed with some compilers that a definition of the form
 >
 > class MyClass {
 > public:
 >   MyClass(int =0);
 >   MyClass();
 > };
 >
 >isn't immediately flagged as an error (the error comes when you try to invoke
 >the default constructor).
 >
 >Does the standard have anything to say about this?

Yes. Section 13.1 "Overloadable declarations" describes what sort of
overloading is not allowed, and says everything else is allowed.

Examples like this are not disallowed, and the draft even gives a
similar example showing that it is OK.


Steve Clamage, stephen.clamage_nospam@eng.sun.com
( Note: remove "_nospam" when replying )
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]