Skip to content

Update DecoratorPattern.cpp#5

Open
Ishan-Mittal69 wants to merge 1 commit intoadityatandon15:mainfrom
Ishan-Mittal69:patch-1
Open

Update DecoratorPattern.cpp#5
Ishan-Mittal69 wants to merge 1 commit intoadityatandon15:mainfrom
Ishan-Mittal69:patch-1

Conversation

@Ishan-Mittal69
Copy link

fix: prevent memory leak by adding destructor in CharacterDecorator

Previously, only StarPowerUp defined a destructor, which caused leaks when Mario was wrapped with other decorators (e.g. HeightUp, GunPowerUp). Now CharacterDecorator deletes its wrapped Character, ensuring the entire decorator chain is cleaned up when the outermost object is deleted.

fix: prevent memory leak by adding destructor in CharacterDecorator

Previously, only StarPowerUp defined a destructor, which caused leaks
when Mario was wrapped with other decorators (e.g. HeightUp, GunPowerUp).
Now CharacterDecorator deletes its wrapped Character, ensuring the entire
decorator chain is cleaned up when the outermost object is deleted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant