This is a discussion on Difference between a "assignment operator" and a "copy constructor"? within the C and C++ Programming forums, part of the Software Development category; Hi pals please let me know the Difference between a "assignment operator" and a "copy constructor"?...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| The copy constructor is creating a new object. The assignment operator has to deal with the existing data in the object. For a simple class, the work done may be the same, but for more complex classes, especially those with pointers to other objects, we will have more to do. This is related to the deep and shallow copy issue, and ownership and is-a-part relationships. |
| |||
| (I) Copy Constructor:
A variable is declared which is initialized from another object Point p; // calls default constructor point s=p; //calls copy constrctor p=s; //assignment,not copy constructor (II)Assignment Operator:
Thanks, Lavanya.J |
![]() |
| Thread Tools | |
| Display Modes | |
| |
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 01:12 AM |
| Diffrence between a "assignment operator" and a "copy constructor" | Sabari | C and C++ Programming | 1 | 07-24-2007 05:00 AM |
| Difference between "printf" and "sprintf". | Sabari | C and C++ Programming | 1 | 07-23-2007 06:23 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 04:38 AM |
| Difference between "APPLET" and "APPLICATION" | prasath | Java Programming | 1 | 07-17-2007 07:51 AM |