Since I see people not getting C++ (more specific: OOP) I'm going to spill it out. Let's take this example from C::B (app.cpp):
class Splash
{
public:
Splash(const bool show) : m_pSplash(nullptr)
{
if (show)
{
wxBitmap bmp = cbLoadBitmap(ConfigManager::ReadDataPath() + _T("/images/splash_1312.png"));
wxMemoryDC dc;
dc.SelectObject(bmp);
cbSplashScreen::DrawReleaseInfo(dc);
dc.SelectObject(wxNullBitmap);
m_pSplash = new cbSplashScreen(bmp);
Manager::Yield();
}
}
~Splash()
{
Hide();
}
void Hide()
{
if (m_pSplash)
{
m_pSplash->Destroy();
m_pSplash = nullptr;
}
}
private:
cbSplashScreen* m_pSplash;
};
If this is a local code where you get resources, show them and release right after it, you don't even need a class. This class works a lot like function anyway which is a common mistake. But if it is a dynamic resource (the splash screen is kept in memory) then you always want to avoid conditional construction. Do not pass that show boolean to the constructor, but construct the object's data and release it in the destructor. Then use a Show function to show the splash screen. If you are resetting some pointer to nullptr you are most likely doing it wrong. By following constructor/destructor rule you don't have to check out pointers etc.
As a side note this class probably also has a missing delete, at least there is a new but no delete. Might be some wx magic, but not sure about it.
But the main point is that this is not a class. It's a function and if you have something like this you don't even need a function, you could simply write the code inside a if block (if the resources are local and used only in one place).