If I have a pointer to a struct/object, and that struct/object contains two other pointers to other objects and I want to delete the "object that contains the two pointers without destroying the pointers it holds" - how do I do that?
Pointer to Object A (Contains Pointer to Object B, Contains Pointer to Object C). Delete Object A Pointer to Object A is deleted, Pointer to Object B / C does still exists.
Is there something that I have to do to make this work?
UPDATE
It's for a game project, I hope this explains it. Right now, I have some "problems" even putting the two pointers to B, C inside the first Struct (A)
struct Player
{
char * Name;
Weapon* PlayerWeapon;
Armor* PlayerArmor;
};
struct Weapon
{
char * Name;
int Damage;
};
struct Armor
{
char * Name;
int Resistance;
};
And this somehow doesn't work.
Player* CreatePlayer(char * Name, Weapon* weapon, Armor* armor)
{
Player *pPlayer = new Player;
pPlayer->Name = name;
pPlayer->Weapon = weapon;
pPlayer->Armor = armor;
};
And later when a player "dies", the equipment should not be deleted.