Quote Originally Posted by StGuru View Post
There is copy created of the ob2. I should use pass by reference if I alter the ob1 variables but I don't alter them.
For example if I need to change something in the object
Function1(test &ob1)
{
ob1.z=5;
}
or something like that.
You're missing the ****ing point.
When you pass T by-value, T's copy constructor gets invoked. In your case, over and over and over. In short, impossible. Passing T by (const) reference alleviates that problem.

If you don't understand this simple concept, perhaps you should stick with shallow copying for now. Besides, that snippet in your OP doesn't require an explicit copy constructor in the first place.