Reputation: 43
I have the following piece of code
void* Class1::operator new(size_t nSize, LPCSTR lpszFileName, int nLine)
{
return ::operator new[](nSize,lpszFileName,nLine);
}
void Class1::operator delete(void *p, LPCSTR lpszFileName, int nLine)
{
::operator delete[] (p,lpszFileName,nLine);
}
I do not understand ::operator new[](nSize,lpszFileName,nLine)
and delete[] (p,lpszFileName,nLine)
. There is a global scope operator "::
" So it is supposed to call C++ operators, but there are no such overloads in C++ specification. Could you explain why is this?
Upvotes: 2
Views: 88
Reputation: 73366
As Holt mentioned, there is a new
operator defined at global scope, like:
void* operator new(size_t, LPCSTR, int);
and is resolved via the scope resolution operator. Same goes for the delete
case.
Upvotes: 1