I'm not new to programming, but it's been many years since I really used C++, and I don't think we even touched on pointers(it was in highschool). Anyways, I have some working code, but since I'm not a pointer expert I wanted to make sure that I was doing this correctly.
Currently, I'm working on a small prototype for a game to kind of help me get some basic ideas down as well as help me get back into the way C++ does things. I'm using SFML and my question really applies to how I have my game screens set up. In each game screen, it holds a pointer to the RenderWindow so that when Draw is called the RenderWindow would not have to be passed before each frame is drawn.
Since the RenderWindow will have its own destructor called all I do is set the pointer to 0. Is that all I really have to do?
Here's some code just to be certain.
This is not all my code, just the code in question. Like I said, I wanted to make sure that I'm doing this correctly. Everything compiles and it runs fine!
tl;dr
Is this an acceptable use of pointers?
class BasicGameScreen
{
private:
//Window used for Rendering
sf::RenderWindow *MainApp;
public:
void Initialize(sf::RenderWindow &App)
{
MainApp = &App;
}
void :Draw()
{
//drawing whatever
MainApp->Draw(Background);
MainApp->Draw(Sprite);
}
~BasicGameScreen()
{
MainApp = 0;
}
}