2

It seems both can be overloaded, but somebody said not.....

What's the case?

Pointy
  • 405,095
  • 59
  • 585
  • 614
skydoor
  • 25,218
  • 52
  • 147
  • 201

3 Answers3

4

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.

Community
  • 1
  • 1
Johannes Schaub - litb
  • 496,577
  • 130
  • 894
  • 1,212
2

You can overload all four of, new, new[], delete, and delete[]. See section 13.5 of the standard.

Matthew Flaschen
  • 278,309
  • 50
  • 514
  • 539
-1

You can overlload new operator but you cannot define new operators(like ^ or ++).

If it is not what you meant please clarify.

Maciej Piechotka
  • 7,028
  • 6
  • 39
  • 61