This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Problem default type converting
- From: Rupert Wood <rup at kanat dot pair dot com>
- To: "Henrik Nilsson (Developer)" <hni at bossmedia dot se>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Tue, 8 Oct 2002 05:06:00 -0400 (EDT)
- Subject: Re: Problem default type converting
On Tue, 8 Oct 2002, Henrik Nilsson (Developer) wrote:
> I'm using GCC 2.96 on Linux
:
> Then I get compiler error.
> Due to the C++ standard my.f("") should create a temp object like this
> my.f(CString("")) but instead I get compiler error
I only have 2.95 to test here, but this code (derived from yours) compiles
cleanly on full warnings:
class CString
{
public:
CString();
CString(const char *);
};
class MyClass
{
public:
void f(const CString &s);
};
int main(void)
{
MyClass my;
my.f("");
return 0;
}
and fails to link citing both MyClass::f and CString::CString(const char*).
Are you sure that you haven't made another mistake? Did you build with
'-Wall'? What's the compiler error? Does my version work?
Alternatively, have you somehow flagged the CString(const char*)
constructor as explicit-only (an __attribute__?) or forbidden implicit
construction via a command line switch? I can't see any that do that from
a quick scan of the manual.
Rup.