constructor selection problem
Paul Kendall
paul@orion.co.nz
Fri Nov 14 12:31:00 GMT 1997
> -----Original Message-----
> From: Michael A. Benzinger [SMTP:mbenz@sabre.com]
> Sent: Saturday, November 15, 1997 2:10 AM
> To: Paul Kendall; 'egcs-bugs@cygnus.com'
> Subject: Re: constructor selection problem
>
> Paul,
>
> You cannot explicitly call a constructor when you new an
> array. The new operator creates arrays of objects by calling
> the default constructor for each element of the array. The
> elements of the array cannot be initialized to distinct values.
>
Then I think the error message is misleading. Perhaps it should
say that there is no default constructor. i.e. "no matching call for
A::A()"
not "no matching call for A::A(int)"
BTW: the parameter type mentioned in this error message is always
the type of the last parameter in the constructor I am trying to invoke.
i.e. if 'b' was a bool, and I was passing '(1,false)' as parameters then
I get "no matching call for A::A(bool)". Clearly there is some kind of
error!
BTW2: gcc-2.7.2.1 must be wrong because it compiles this fine.
And it does what I expect it to!
> Mike Benzinger
>
> At 12:07 PM 11/14/97 +1300, Paul Kendall wrote:
> >Hi,
> >the following code causes this error:
> >"no matching function for call to 'A::A (int)'"
> >"candidates are: A::A(const A &)"
> >" A::A(int, int)"
> >
> >when clearly the code is invoking the (int,int) constructor!
> >
> >class A {
> >public:
> > A(int a, int b) {}
> >};
> >
> >main() {
> > A* a;
> > a = new A[2](1,2);
> >}
>
> -------------------------------------------------------------
> Michael A. Benzinger
> Sr. Manager
>
> SABRE Technology Solutions Phone: +1 817-264-6820
> 1 E. Kirkwood Blvd. Fax: +1 817-264-6808
> Southlake, TX 76092 e-mail: mbenz@sabre.com
> U.S.A. bzinger@iName.com
>
Cheers,
Paul Kendall
Product Development Manager
Orion Systems New Zealand Ltd
More information about the Gcc-bugs
mailing list