You cannot do it reliably. If it were so simple, possible and reliable, then the programmers did not overload operator=() and write copy-constructor.
If you want to make a copy of your object, either overload operator=() , either write copy-constructor, or do both!
source share