Originally Posted by
Paul McKenzie
Well, you've now made your class almost useless in a real program. You've now introduced side-effects in your copy-assignment operations.
The purpose of the copy constructor (and assignment operator, which you didn't implement) is to do just that -- make copies. If you start to make fake copies of your objects using the copy-assignment operator, that opens the code up for a lot of runtime bugs that are insanely difficult to solve.
In other words, what if I tried to create a vector<test> and started to manipulate this vector by resizing it, removing items, etc.? What will happen? Chaos.
When creating a copy constructor and assignment operator, the goal is to make sure that the copied objects acts exactly the same as the original object. In other words, if I take that copy and use it instead of the original object, the code must behave exactly the same externally.
Your property class itself implements the copy constructor with side-effects. Why didn't you copy the std::function members? You only copied the PropertyValue. So already you're in trouble.
If you need to change the object to "almost copy" another object, then provide that function -- do not use the copy constructor or assignment operator for this purpose.
Regards,
Paul McKenzie