In Rastertek DirectX tutorials they have empty constructors and destructors, and instead use a function initialize()and shutdown()to initialize and clean facilities. After some use of this construct, I can somewhat understand the advantages of using the method initialize(), but I donβt see how using the method is shutdown()better than putting all the cleanup code in the destructor.
The reason they are provided is as follows:
You will also notice that I am not clearing an object in a class destructor. Instead, I do all of my objects in the Shutdown function, which you'll see later. The reason is that I do not believe that this will be caused. Some Windows functions, such as ExitThread (), are known for not calling class destructors, which leads to memory leaks. You can, of course, name safer versions of these functions, but I'm just trying to program on windows.
Thus, the general usage pattern is as follows:
class Renderer
{
public:
Renderer() { }
~Renderer() { }
bool initialize(...) { }
void shutdown() { }
};
Renderer* renderer = new Renderer;
renderer->initialize(...);
renderer->shutdown();
delete renderer;
renderer = NULL;
Rastertek, , C ( , ..), , , ++ ( ). ?