can someone explain to me this paragraph from C++ primer 5th edition:
Terminology: new Expression versus operator new Function
The library functions operator new and operator delete are misleadingly named. Unlike other operator functions, such as operator=, these functions do not overload the new or delete expressions. In fact, we cannot redefine the behavior of the new and delete expressions.
A new expression always executes by calling an operator new function to obtain memory and then constructing an object in that memory. A delete expression always executes by destroying an object and then calling an operator delete function to free the memory used by the object.
By providing our own definitions of the operator new and operator delete functions, we can change how memory is allocated. However, we cannot change this basic meaning of the new and delete operators.
I don't see a difference between operator new
or operator delete
and any other overloaded operator like the assignment operator =
. So what it means "are misleadingly named"? and we all know that we don't override an expression like fObj + fObj
but we overload the operator not the expression itself.
In fact I find this paragraph itself misleading. After all we can "abuse" any overloadable operator and from which operator new
and delete
so what did he mean in this paragraph? Thank you!