"Shark" <cp*******@yahoo.com> wrote in message news:11**********************@g44g2000cwa.googlegr oups.com...
Hi, if we need to change the behavior of operator new, it is called
overriding or overloading? My other question is, if we change the
behavior of operator new, do we use malloc to do that or we use
operator new?
It is not clear what you want. C++ has several operators new. Which one do you need to change?
C++ has the possibility to define a new operator for a class. This is the safest way to go.
It is also possible to override the global new operators, but this needs a lot of care,
since these global new operators are also used in the C++ library functions.
(This means that on many platforms the standard operator new sits already in the shareable libraries,
so you should use a static link to get a consistent use of the changed new operators.)
In addition you should change the delete operators as well to match your new operators.
You could use malloc and free.
F.Z.