Many times, I need to create objects with fields whose size is unknown until the time of construction or later. To accomplish this, I leave those fields as ptr_new() until I know what size arrays I need. I know that we cannot overload the assignment operator, but copying each element field for field breaks encapsulation, as changing one class can alter the contents of multiple classes.
Is there any way around this? How can I prevent this from happening?
Thanks for any help
|