IT Community - Software Programming, Web Development and Technical Support

Diffrence between a "assignment operator" and a "copy constructor"

This is a discussion on Diffrence between a "assignment operator" and a "copy constructor" within the C and C++ Programming forums, part of the Software Development category; Diffrence between a "assignment operator" and a "copy constructor"?...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C and C++ Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-23-2007, 12:13 AM
Sabari Sabari is offline
D-Web Genius
 
Join Date: Jul 2007
Posts: 1,008
Sabari is on a distinguished road
Exclamation Diffrence between a "assignment operator" and a "copy constructor"

Diffrence between a "assignment operator" and a "copy constructor"?
__________________
Thanks & Regards
Sabari...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-24-2007, 04:00 AM
vijayanand vijayanand is offline
D-Web Analyst
 
Join Date: Feb 2007
Posts: 293
vijayanand is on a distinguished road
Default Re: Diffrence between a "assignment operator" and a "copy constructor"

1. Constructor with only one parameter of its same type that assigns to every nonstatic class member variable of the object a copy of the passed object

2. Copy assignment operator must correctly deal with a well constructed object - but copy constructor initializes uninitialized memory

3. Copy constructor takes care of initialization by an object of the same type x

4. For a class for which the copy assignment and copy constructor not explicitly declared missing operation will be generated by the compiler. Copy operations are not inherited - copy of a class object is a copy of each member

5. Member wise assignment: each member of the right hand object is assigned to the corresponding member of the left hand object

6. If a class needs a copy constructor it will also need an assignment operator

7. Copy constructor creates a new object, assignment operator has to deal with existing data in the object

8. Assignment is like deconstruction followed by construction

9. Assignment operator assigns a value to a already existing object

10. Copy constructor creates a new object by copying an existing one

11. Copy constructor initializes a freshly created object using data from an existing one. It must allocate memory if necessary then copy the data

12. The assignment operator makes an already existing object into a copy of an existing one.

13. Copy constructor always creates a new object, assignment never does
__________________

J.Vijayanand
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I keep getting "Data Missing" when I click the "back" button in my browser. How can I oxygen HTML, CSS and Javascript Coding Techniques 1 07-28-2007 12:12 AM
Write any small program that will compile in "C" but not in "C++" Sabari C and C++ Programming 1 07-24-2007 03:48 AM
What is the difference between "calloc" and "malloc"? Sabari C and C++ Programming 1 07-23-2007 05:08 AM
Why do I get "HTTP 500" error(or "(DLL)initialization routine failed")in my browser? kingmaker ASP and ASP.NET Programming 1 07-20-2007 03:38 AM
Difference between a "assignment operator" and a "copy constructor"? vigneshgets C and C++ Programming 2 07-12-2007 04:30 AM


All times are GMT -7. The time now is 02:54 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0