A simple question but I am not sure what it is done in C++.
When I have a class that have _bstr_t member. I would like to know if does member are freed when the object is deleted:
class A {
_bstr_t foo("Testing");
}
The A
class does not have a dtor. So is the default dtor calling the dtor of yeach member of the class A
?
Especially for _bstr_t because it allocate a string v开发者_高级运维ia SysAllocString.
Thanks
Yes, _bstr_t
destructor will have been called - the compiler will take care of that. Even though it doesn't have a user-defined destructor the compiler will emit code that destroys all fully constructed subobjects by calling their destructors.
Since _bstr_t
has a non-trivial destructor that takes care of calling SysFreeString()
that destructor will be called and release the BSTR.
精彩评论