Although we say that we can “overload
delete,” overloading these operators is quite different from the way we overload other operators. In order to understand how we overload these operators, we first need to know a bit more about how
delete expressions work.
When we use a
// new expressionsstring *sp = new string("a value"); // allocate and initialize a stringstring *arr = new string; // allocate ten default initialized strings
three steps actually happen. First, the expression calls a library function named
operator new). This function allocates raw, untyped memory large enough to hold an object (or an array of objects) of the specified type. Next, the ...