question regarding operator overloading!
-
can the operators 'new' and 'delete' be overloaded? "faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
-
can the operators 'new' and 'delete' be overloaded? "faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
-
can the operators 'new' and 'delete' be overloaded? "faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
Yes, new and delete operators can be overloaded. Use the following signatures. 1.) new :-
void* operator new( size_t p_stBlock );
2.) delete :-void operator delete( void* p );
Rahim Rattani Software Engineer, Matrix Systems (Pvt) Ltd., Karachi - Pakistan -
can the operators 'new' and 'delete' be overloaded? "faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
It's slightly complicated in that you can overload
operator new
andoperator delete
but you can't overload the new and delete operators in the same sense as overloading, say '+'. The reason is that your overloadedoperator `new is only responsible for allocating memory, but someone must call the constructor, right? Same goes for delete, you can free memory, but someone must call the destructor. Regards Senthil _____________________________ [My Blog](http://blogs.wdevs.com/senthilkumar) | [My Articles](http://www.codeproject.com/script/articles/list_articles.asp?userid=492196) | [WinMacro](http://geocities.com/win_macro)`
-
It's slightly complicated in that you can overload
operator new
andoperator delete
but you can't overload the new and delete operators in the same sense as overloading, say '+'. The reason is that your overloadedoperator `new is only responsible for allocating memory, but someone must call the constructor, right? Same goes for delete, you can free memory, but someone must call the destructor. Regards Senthil _____________________________ [My Blog](http://blogs.wdevs.com/senthilkumar) | [My Articles](http://www.codeproject.com/script/articles/list_articles.asp?userid=492196) | [WinMacro](http://geocities.com/win_macro)`
Thank u senthil kumar! for ur answer!but i kinda didnt follow that last line you quoted! how is it different from the other operator overloaded types? cheerz..... "faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13