I’m using a copy constructor to take a MapObject and copy it and it’s properties.
However, this object is already spawned into the game, so on construction I want to remove the object from the game.
Essentially, what I’m trying to do is this:
MapObject::MapObject(const MapObject& _mapobject)
{
_mapobject.Derez();
Rez();
}
How can I accomplish that in the copy constructor without calling it on const&?
Edit:
Switching to a vector of smart pointers solved this issue altogether.
You can only call it if
Derezisconst.But to me, it seems like the design is wrong. Why creating a copy removes the original from the game? Why is the class responsible for removing instances of itself from the game in the first place? Why are you even trying to copy an object that’s already in the game?
To me, this seems more important than actually calling that method.