I have a question about copy constructors/copying objects.
I have a class that has a few properties that I don’t want to be copied.
class Action : public Cloneable<Action>
{
public:
//Constructors and other methods are ommitted
std::vector<BattleCharacter*> Users;
std::vector<ActionTargetTuple> Targets;
protected:
ActionType Type;
std::string Name;
int UID;
}
I want the Users and Targets vectors NOT to be copied when I make a copy of this type of object. Is there a way to mark them as explicitly not copyable without using a custom copy constructor? If not, and I use a custom copy constructor, will I need to define a custom copy constructor for each class that inherits from this one?
The default copy constructor will copy everything, so yes – you will need to implement the copy constructor manually to achieve this. As this replaces the default copy ctor, you will not need to define one for each inherited class (unless you want different behavior).