Hi,
Here's the other warning I receive when I compile the source code.
//------------------------
warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
//------------------------
The line incriminated is between two lines like this: //------------------------
----------
----------
----------
----------
---------
Here's all the code
//************************
*** BEGINNING OF THE CODE
#ifndef cUnknownPtr_DEFINED
#define cUnknownPtr_DEFINED
template <typename T>
class cUnknownPtr
{
T* ptr;
public:
cUnknownPtr() : ptr(0)
{
}
cUnknownPtr(T* p) : ptr(p)
{
}
cUnknownPtr(const cUnknownPtr<T>& other) : ptr(other.ptr)
{
if(ptr)
{
ptr->AddRef();
}
}
~cUnknownPtr()
{
setNull();
}
cUnknownPtr<T>& operator = (const cUnknownPtr<T>& other) //treat as pointer
{
if(other.ptr != ptr)
{
if(ptr)ptr->Release();
ptr = other.ptr;
if(ptr)ptr->AddRef();
}
return *this;
}
T* operator -> () //treat as pointer
{
return ptr;
}
operator T* () //silent cast operator
{
return ptr;
}
T** operator & () //address of operator
{
return &ptr;
}
bool isValid()
{
return ptr != 0;
}
bool isNull()
{
return ptr == 0;
}
void setNull()
{
if(ptr)
{
ptr->Release();
ptr = 0;
}
}
bool QI(REFIID riid,void** ppObj)
{
if(isNull())return false;
return SUCCEEDED(ptr->QueryInterf
ace(riid,p
pObj));
}
//------------------------
----------
----------
----------
----------
------
void demandQI(REFIID riid,void** ppObj) throw(HRESULT)
//------------------------
----------
----------
----------
----------
------
{
if(isNull())throw E_FAIL;
HRESULT hr = ptr->QueryInterface(riid,p
pObj);
if(FAILED(hr))
{
throw hr;
}
}
};
inline void checkResult(HRESULT r)
{
if (FAILED(r))
throw r;
}
#endif//cUnknownPtr_DEFINE
D
//************************
*** END OF THE CODE
THANKS YOU FOR ANY ADVICE...
Start Free Trial