Operator Overloading - One of the important pillars of the Object Oriented Concept is a very useful tool in the hands of the right programmer.
The fact that you can even Overload the NEW operator and the DELETE operator as well adds convenience to the custom memory management.
1. Overloading the NEW Operator:
void *operator new(size_t size, int setvalue)
{
void *pointer;
p = malloc(size);
if(p==NULL)
outofMemory( );
memset(pointer,setvalue,size);
return(p);
}
void outofMemory( )
{
cout<<"OOPS ran out of free memory..";
exit(1);
{.....perform other memory freeing operations here and try to re-allocate the memory....}
}
Microsoft launches DreamSpark in India!
-
On 5th November 2008, Microsoft unveiled *DreamSpark* - a software giveaway
for an estimated 10 million eligible students in India. DreamSpark will
provi...

1 comment:
Cool Stuff, can you check out my C++ Code Samples too?
Post a Comment