inline void SafeRelease(IUnknown * &rpUnk)
{
if (rpUnk)
{
rpUnk->Release();
rpUnk = 0;
}
}IEnumGUID* pIEnumGUID = NULL;
// .......
SafeRelease(pIEnumGUID);error C2664: 'SafeRelease' : cannot convert parameter 1 from 'struct IEnumGUID *' to 'struct IUnknown *& '
A reference that is not to 'const' cannot be bound to a non-lvalue
{
if (rpUnk)
{
rpUnk->Release();
rpUnk = 0;
}
}IEnumGUID* pIEnumGUID = NULL;
// .......
SafeRelease(pIEnumGUID);error C2664: 'SafeRelease' : cannot convert parameter 1 from 'struct IEnumGUID *' to 'struct IUnknown *& '
A reference that is not to 'const' cannot be bound to a non-lvalue
应该能编译过,但意义不清楚俺不明白为什么用这样的参数,俺的c++功底不够
而调用方却按照C的方式来编译。
#define SafeRelease(x)if(x){(x)->Release();(x)=NULL};