Original Post
🔒 Locked
Class deallocation
Advertisement
quote:
Original post by mdfmKoRn
Am I right in assuming that, for example, if you declared a LPDIRECTX8 object or whatever inside another object, (say class Game) the memory will be free when the encapsulating object''s destructor is called?
No. You must write code to make this happen.
If the object is allocated on the stack, it will be freed automatically. If you use new, you must delete, if you new[] you must delete[], if you create a COM object you must call ->Release()
If you want them to automatically be released, you need to use smart pointers.
|
The CComPtr template will call ->Release when the instance of MyClass is destroyed.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement