Hi to all ,
so can u tell this answer plz,,,,,,what is the use and where to use of overloading new and delete operator in c++.
2-if what is the return type of global new if it fails to allocate memory,how we know it fails to allocate memory if we are not using execption handler ,is there any way.
the overriding is for allocating memory in your own way, say you have a class with two member variables, and you want to keep them with some offset in memory. In this case, indeed, you should also override the delete operator. As far as I know, the if operator new cannot allocate memory it returns a null pointer, but the type is the same:
1 2 3 4 5 6
int * pi = newint[20];
if (0 != pi) {
//do whatever you want
// .............
}
delete [] pi;