From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gabriel Dos_Reis To: kabatek@chemie.uni-halle.de Cc: egcs@egcs.cygnus.com, egcs-bugs@egcs.cygnus.com Subject: Re: Strange warnings Date: Mon, 31 May 1999 21:36:00 -0000 Message-ID: References: X-SW-Source: 1999-05n/msg00112.html Message-ID: <19990531213600.drteUqOwCZyqYitTjZDwqwjAbpfpNNmo8OpuMs9PmCQ@z> Ryszard Kabatek writes: | In the sample below the class X should have a standard constructor | generated by the compiler. But I get the following warnings: | | # eg++ x.cc | x.cc:6: warning: `class X' only defines private constructors and has no | friends | x.cc: In function `static class X * X::create()': | x.cc:5: no matching function for call to `X::X ()' | x.cc:3: candidates are: X::X(const X &) EGCS gets it right. The Standard says: 12.1/5 --- A default constructor for a class X is a constructor of class X that can be called without an argument. If there is no user-defined constructor for class X, a default constructor is implicitly declared ... --- Since you declared X::X(const X&), the default constructor is not implicitly declared and it is up to you do so and give it a semantic. | The first warning I get too if I define a private standard constructor. | But there is a static function, that creates new instances of X, | class X does not need friend functions or classes. It is two way :-) : it can be helpful and quite inappropriate. -- Gaby