Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on Copy Constructor within the C and C++ forums, part of the Software Development category; While we create a copy constructor Is this code coreect or wrong? class a { public: a(a &b) {} }...
|
|||||||
|
|||
|
Copy Constructor
While we create a copy constructor Is this code coreect or wrong?
class a { public: a(a &b) {} } |
| The Following User Says Thank You to manoj200724 For This Useful Post: | ||
| Sponsored Links |
|
|||
|
Quote:
This is absolutely correct. const is required to prevent the passing object being changed by copy constructor code. Last edited by vikram_lok; 12-12-2007 at 02:50 AM. |
|
|||
|
Re: Copy Constructor
that code is correct,but if u create a constant object then dt code is not correct,u have to write const classname&,like dt.ok,,,,,,,if u do not write const object then dt code is ok.
|
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| constructor | emb.mallik | C and C++ | 1 | 03-02-2009 04:50 PM |
| Class copy constructor and assignment operator | Geek_Guest | C and C++ | 1 | 12-21-2007 05:49 AM |
| Constructor and init() | pramod.kuber | Java | 3 | 11-04-2007 02:42 AM |
| why i am getting an error while calling a constructor from another constructor | raj_java_j2ee | Java | 4 | 07-22-2007 03:39 AM |
| Silent Copy - copy your files with the convenience! | JobHelper | Geeks Lounge | 0 | 04-05-2007 04:40 AM |