Question about (CX?) destructor?
-
In the DirectX metro sample one can find a class named DirectXBase with roughly this header:
ref class DirectXBase abstract
{
public:
DirectXBase();virtual void Render() = 0; virtual void Present(); // ....
protected:
Microsoft::WRL::ComPtr m\_d2dFactory; Microsoft::WRL::ComPtr m\_d2dDevice; Microsoft::WRL::ComPtr m\_d2dContext; Microsoft::WRL::ComPtr m\_d2dTargetBitmap; // ....
};
What I find strange is that there is no destructor! What about all those ComPtr? are they automatically set to null because it's a ref class? is it a bug?
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station.... _________________________________________________________ My programs never have bugs, they just develop random features.
-
In the DirectX metro sample one can find a class named DirectXBase with roughly this header:
ref class DirectXBase abstract
{
public:
DirectXBase();virtual void Render() = 0; virtual void Present(); // ....
protected:
Microsoft::WRL::ComPtr m\_d2dFactory; Microsoft::WRL::ComPtr m\_d2dDevice; Microsoft::WRL::ComPtr m\_d2dContext; Microsoft::WRL::ComPtr m\_d2dTargetBitmap; // ....
};
What I find strange is that there is no destructor! What about all those ComPtr? are they automatically set to null because it's a ref class? is it a bug?
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station.... _________________________________________________________ My programs never have bugs, they just develop random features.
Well, it's an abstract class... and all those are pointers. So if they were never allocated, they don't need to be destroyed.
-
In the DirectX metro sample one can find a class named DirectXBase with roughly this header:
ref class DirectXBase abstract
{
public:
DirectXBase();virtual void Render() = 0; virtual void Present(); // ....
protected:
Microsoft::WRL::ComPtr m\_d2dFactory; Microsoft::WRL::ComPtr m\_d2dDevice; Microsoft::WRL::ComPtr m\_d2dContext; Microsoft::WRL::ComPtr m\_d2dTargetBitmap; // ....
};
What I find strange is that there is no destructor! What about all those ComPtr? are they automatically set to null because it's a ref class? is it a bug?
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station.... _________________________________________________________ My programs never have bugs, they just develop random features.
If whatever god foresaken language you're using works like C++ then the compiler will generate a default constructor for you. This default destructor will call the destructors for the data members for you (in the reverse order they were constructed). If it doesn't work like C++ then all bets are off :-). Cheers, Ash