It seems both can be overloaded, bu开发者_运维百科t somebody said not.....
What's the case?
It seems you are making the distinction between the handling of new-expressions and allocation functions. new-expressions call constructors in addition for class types and is responsible for looking up allocation functions (so it is built into the compiler) and calling them. You can't change that behavior. What you can change is the behavior of allocation functions. Their name is operator new
and they are found and used by new-expressions to allocate memory.
See Plain new, new[], delete and delete[] in a nutshell.
You can overload all four of, new
, new[]
, delete
, and delete[]
. See section 13.5 of the standard.
You can overlload new
operator but you cannot define new operators(like ^
or ++
).
If it is not what you meant please clarify.
精彩评论