I have a function that i'm using to delete buffers. The pointers are passed by address so that the function can also unset them once the memory is released :
static void _FreeBuf( const uchar16_t ** pBufPtr );
void Ucs2String::_FreeBuf( const uchar16_t ** pBufPtr );
{
assert( NULL != pBufPtr && NULL != *pBufPtr );
delete[] *pBufPtr;
*pBufPtr = NULL;
}
But when using it as follows :
_FreeBuf( & m_wsBuf );
Where m_wsBuf
is a member : uchar16_t * m_wsBuf;
It generates an error :
Error 1 error C2664: 'core::Ucs2String::_FreeBuf' : cannot convert parameter 1 from 'uchar16_t **__w64 ' to 'const uchar16_t **'
Removing the const fixes the issue, but I don't understand why. The function is modifying the pointer passed by address, not the const uchar16_t array pointed to, so why do I need to remove this const ?
PS : I'm using VS2005 (and no C++11)