s it safe to pass CComVariant declared locally ot other function
-
Is it safe to pass CComVariant declared locally to other function 1. Can I pass the CommVariant to other function, when not created using new ? 2. Should I free it/delete expecitly some where ? 3. Is it safe ? any precauions ?
CComVariant comVart;
comVariant.vt = VT_I4;
comVariant.intVal = 10;
SendComVariantToOtherFunction(comVart);
Thanks in advance!! -
Is it safe to pass CComVariant declared locally to other function 1. Can I pass the CommVariant to other function, when not created using new ? 2. Should I free it/delete expecitly some where ? 3. Is it safe ? any precauions ?
CComVariant comVart;
comVariant.vt = VT_I4;
comVariant.intVal = 10;
SendComVariantToOtherFunction(comVart);
Thanks in advance!!ptr_Electron wrote:
1. Can I pass the CommVariant to other function, when not created using new ?
Yes.
ptr_Electron wrote:
2. Should I free it/delete expecitly some where ?
No, when not allocated on the heap. When using
new
, it must be of course freed usingdelete
. Everything else is done by the destructor.ptr_Electron wrote:
3. Is it safe ? any precauions ?
It is safe. But you must take care when assigning data (type and data must match).