Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy constructor shortcut

I have a class with about 50 members. 1 of them is a pointer. So, naturally I have to make my own copy constructor, copy everything and create a new instance of that object. My question is: Is there a shortcut or some special way I can have everything copied (like the default copy constructor does) then just handle that one pointer? Rather than manually copying each member.

like image 367
steveo225 Avatar asked Jan 28 '26 02:01

steveo225


1 Answers

I'd wrap your pointer into a helper class that does the copy in the way you like. That way you can leave the big class with the default copy ctor.

like image 135
mitchnull Avatar answered Jan 29 '26 16:01

mitchnull