Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Re: Overload re...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 9 of 11 Topic 45791 of 47034
Post > Topic >>

Re: Overload resolution and copy constructors that take non-const

by Branimir Maksimovic <bmaxa@[EMAIL PROTECTED] > May 7, 2008 at 03:18 PM

On May 7, 4:25=A0pm, "Victor Bazarov" <v.Abaza...@[EMAIL PROTECTED]
> wrote:
> Branimir Maksimovic wrote:
> > It will call copy constructor all right, but
> > still gives error that it wants A(A)
>
> Sorry, I don't know what you mean here.
>

I had to wait several hours to be sure that this is
not already sent, because I clicked send twice
but google didn't confirmed.
Ok, following program does not compiles:

class A{
public:
  A(){}
  A(A&){}
};

A foo()
{
  A a;
  return a;
}

int main()
{
  A a;
  a =3D foo();
}

bmaxa@[EMAIL PROTECTED]
 g++ -Wall cctor.cpp -o cctor
cctor.cpp: In function =91int main()=92:
cctor.cpp:16: error: no matching function for call to =91A::A(A)=92
cctor.cpp:4: note: candidates are: A::A(A&)

Since tem****ary is constructed by local variable now, I think
that this should compile since A::A(A&) should be called.
 But I got same error again.
That is what confuses me. Is compiler right or should
this compile?
Thanks for your time (I'm really rusty with English language)

Greetings, Branimir.
 




 11 Posts in Topic:
Overload resolution and copy constructors that take non-const re
Anthony Williams <anth  2008-05-07 10:44:48 
Re: Overload resolution and copy constructors that take non-cons
Branimir Maksimovic <b  2008-05-07 05:54:26 
Re: Overload resolution and copy constructors that take non-cons
"Victor Bazarov"  2008-05-07 08:59:18 
Re: Overload resolution and copy constructors that take non-cons
Branimir Maksimovic <b  2008-05-07 06:21:21 
Re: Overload resolution and copy constructors that take non-cons
Branimir Maksimovic <b  2008-05-07 06:40:00 
Re: Overload resolution and copy constructors that take non-cons
"Victor Bazarov"  2008-05-07 10:25:23 
Re: Overload resolution and copy constructors that take non-cons
dizzy <dizzy@[EMAIL PR  2008-05-07 17:47:00 
Re: Overload resolution and copy constructors that take non-cons
"Victor Bazarov"  2008-05-07 11:33:53 
Re: Overload resolution and copy constructors that take non-cons
Branimir Maksimovic <b  2008-05-07 15:18:46 
Re: Overload resolution and copy constructors that take non-cons
"Alf P. Steinbach&qu  2008-05-08 00:34:33 
Re: Overload resolution and copy constructors that take non-cons
James Kanze <james.kan  2008-05-09 03:28:52 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 3:02:18 CDT 2008.