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 via SysAllocString.
Thanks
Yes,
_bstr_tdestructor 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_thas a non-trivial destructor that takes care of callingSysFreeString()that destructor will be called and release the BSTR.