468,512 Members | 1,429 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

copy construct and overloading = operator

As we know that both copy constructors and overloading = opeartor copies one object to another then whats the difference between copy constructor and overloading = operator. There must be some difference ... right?
Aug 21 '06 #1
2 3232
As we know that both copy constructors and overloading = opeartor copies one object to another then whats the difference between copy constructor and overloading = operator. There must be some difference ... right?
the differeces are :-
Copy constructor is invoked when objects are initialized ;) for ex.
1.when a new object is constructed and initialized with the existing object.
--- CLASS a = b; and CLASS a(b); //b is already existing object.

2.when objects are passed as arguement to the function then copy constructor is invoked

3.when a function returns by value then copy constructor is invoekd.

Overloading = opertator is called when objects are copied or during assignment :) .
ex. CLASS a; CLASS b; a=b;

I think this will help you.
Aug 21 '06 #2
Thanks pradeep... but i wanna know i terms of memory allocation. i mean in copy constructors we use reference to an existing object but how exactly in assignment operator..
in short i just wanna know everything about it in terms of memory and nothing else...
Aug 23 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by Kelly Mandrake | last post: by
10 posts views Thread by ambar.shome | last post: by
18 posts views Thread by sd2004 | last post: by
10 posts views Thread by utab | last post: by
15 posts views Thread by subramanian100in | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.