From what I understand, I think that I do not need to free std::strings as the program automatically frees those. I am not sure regarding CStrings, although I also believe that the program handles those.
What I know is that from the many string types in C++, only BSTR require freeing if you have called AllocSysString on it or equate it to NULL.
Can you help me understand why you need to free BSTR and not std::string, CString, etc.?
From what I understand, I think that I do not need to free std::strings as the program automatically frees those
Not quite. It isn't the program that frees the std::string, it's the std::string class itself that does the "freeing" when the variable goes out of scope. When the destructor of std::string is invoked, the memory that the std::string allocated is deallocated automatically.
I am not sure regarding CStrings, although I also believe that the program handles those.
Again, it isn't the "program" doing this -- it's CString's desctructor that does this.
What I know is that from the many string types in C++, only BSTR require freeing if you have called AllocSysString on it or equate it to NULL.
Well, this goes back to my earlier statements.
BSTR is not a C++ class, therefore it knows nothing by itself of when it goes out of scope or will not be used anymore.
Bookmarks