Error in the c++ track. There is an error in the example in the theory about pointers

In the “Accessing member variables” section:

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;

dianaPrincess is the pointer for wonder_woman variables and this variable is allocated on stack so you don’t need to make cleanup here.

1 Like

@IsaacG Can you move this to the C++ category?
@vaeng @siebenschlaefer To your attention.

1 Like