Wrong delete instruction in exercise introduction

In the introduction of SpeedyWaggon there is this code snippet:

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; 

The delete expression should not be there

Why should it not be there?

yoavsal is correct.

In that code snippet wonder_woman is an “automatic variable” (in layman’s terms: it lives on the stack). It will be destructed when it goes out of scope. dianaPrince is a pointer to that object, delete-ing it invokes undefined behavior.

delete is for objects that were dynamically allocated with new.

@yoavsal Do you want to create a pull request for the introduction, that deletes the two lines?

If not (which is perfectly fine) I will do that.