|
-
April 27th, 2009, 10:48 AM
#8
Re: class constructor question
 Originally Posted by StGuru
I should use pass by reference if I alter the ob1 variables but I don't alter them.
There is another reason to use pass by reference: to avoid copying the object. If you do not want to modify the object through the reference then pass by const reference.
 Originally Posted by StGuru
There is copy created of the ob2.
Indeed. And the act of copying invokes the copy constructor, which happens to be precisely what you are trying to implement. So what you are saying is this: I want to copy the object in order to implement copying of the object. That does not make sense.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|