-
-
Notifications
You must be signed in to change notification settings - Fork 237
Closed
Description
| delete dianaPrince; |
A stack defined variable should not be deallocated
struct Superhero {
std::string superpower;
};
Superhero wonder_woman{};
Superhero* dianaPrince = &wonder_woman;
dianaPrince->superpower = "Lasso of Truth";
// Using the -> operator to access member variable superpower:
std::cout << "Wonder Woman, possesses the mighty " << dianaPrince->superpower;
// Memory cleanup:
delete dianaPrince; <<===== WRONGsiebenschlaefer
Metadata
Metadata
Assignees
Labels
No labels