Quote Originally Posted by tridion
Could someone answer the following questions for me :

1. Discuss this C++ code fragment. Do you see any potential problems ?

BSTR bsValue = _bstr_t("a string");
pComInterface->DoSomething(bsValue);
Yes, I see problems.

1) no definition of what BSTR is.
2) _bstr_t is not a standard C++ function
3) pComInterface is not defined.
4) The prototype for DoSomething is not given.

You assume that C++ means Windows, and that is not the case. A UNIX C++ programmer will more than likely not know what in the world you're talking about when you mention BSTR, _bstr_t .... Therefore the problem is the question you asked.
3. What are the errors in this C++ code fragment ? Consider both errors that would prevent succesful compilation and errors that would lead to unexpected behaviour when using these classes.
In addition to what others have pointed out with the problem with the wrong form of "delete", the base class does not follow the "rule of three". Please look up that answer for yourself.

Regards,

Paul McKenzie