Click here to Skip to main content
15,924,679 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Overloading operator new Pin
Roger Stoltz8-Mar-06 11:39
Roger Stoltz8-Mar-06 11:39 
GeneralRe: Overloading operator new Pin
hint_548-Mar-06 11:59
hint_548-Mar-06 11:59 
AnswerRe: Overloading operator new Pin
Ryan Binns8-Mar-06 17:21
Ryan Binns8-Mar-06 17:21 
GeneralRe: Overloading operator new Pin
Nibu babu thomas8-Mar-06 17:36
Nibu babu thomas8-Mar-06 17:36 
GeneralRe: Overloading operator new Pin
Ryan Binns8-Mar-06 17:48
Ryan Binns8-Mar-06 17:48 
GeneralRe: Overloading operator new Pin
toxcct8-Mar-06 21:26
toxcct8-Mar-06 21:26 
GeneralRe: Overloading operator new Pin
hint_549-Mar-06 4:19
hint_549-Mar-06 4:19 
GeneralRe: Overloading operator new Pin
hint_549-Mar-06 4:17
hint_549-Mar-06 4:17 
Ryan Binns wrote:
Do you need to be able to call the old version?


Yes, I do. The overloaded version of the operator should be inside a namespace. So I could do:

CSomething *p;<br />
p = new CSomething; // Standard version of new<br />
p = nMyNamespace::new CSomething; // Overloaded<br />
<br />
{ // Begin scope<br />
 using namespace nMyNamespace;<br />
 p = ::new CSomething; // Standard version<br />
 p = new CSomething; // Overloaded version<br />
} // End scope



Ryan Binns wrote:
Just make sure you overload delete as well, to call free()


I've read somewhere that operator new expands to a call of malloc() and that delete expands to free(). But I'm not shure where that was or if it was a reliable source. So, for now i'll stick to calling the global version of the operator from inside the overloaded version.

regards [[]]


hint_54
GeneralRe: Overloading operator new Pin
Ryan Binns9-Mar-06 12:08
Ryan Binns9-Mar-06 12:08 
QuestionImmediate Dialog Close by Cancel Button Pin
thelvaci8-Mar-06 8:32
thelvaci8-Mar-06 8:32 
AnswerRe: Immediate Dialog Close by Cancel Button Pin
Mircea Puiu8-Mar-06 8:55
Mircea Puiu8-Mar-06 8:55 
GeneralRe: Immediate Dialog Close by Cancel Button Pin
thelvaci8-Mar-06 9:20
thelvaci8-Mar-06 9:20 
GeneralRe: Immediate Dialog Close by Cancel Button Pin
Mircea Puiu8-Mar-06 9:33
Mircea Puiu8-Mar-06 9:33 
AnswerRe: Immediate Dialog Close by Cancel Button Pin
Nibu babu thomas8-Mar-06 17:15
Nibu babu thomas8-Mar-06 17:15 
GeneralRe: Immediate Dialog Close by Cancel Button Pin
thelvaci8-Mar-06 22:00
thelvaci8-Mar-06 22:00 
AnswerRe: Immediate Dialog Close by Cancel Button Pin
Ryan Binns8-Mar-06 17:22
Ryan Binns8-Mar-06 17:22 
GeneralRe: Immediate Dialog Close by Cancel Button Pin
thelvaci8-Mar-06 22:12
thelvaci8-Mar-06 22:12 
GeneralRe: Immediate Dialog Close by Cancel Button Pin
Ryan Binns8-Mar-06 22:19
Ryan Binns8-Mar-06 22:19 
GeneralRe: Immediate Dialog Close by Cancel Button Pin
thelvaci9-Mar-06 1:02
thelvaci9-Mar-06 1:02 
AnswerRe: Immediate Dialog Close by Cancel Button Pin
Aqueel8-Mar-06 17:45
Aqueel8-Mar-06 17:45 
GeneralRe: Immediate Dialog Close by Cancel Button Pin
Nibu babu thomas8-Mar-06 18:09
Nibu babu thomas8-Mar-06 18:09 
GeneralRe: Immediate Dialog Close by Cancel Button Pin
toxcct8-Mar-06 21:16
toxcct8-Mar-06 21:16 
GeneralRe: Immediate Dialog Close by Cancel Button Pin
Nibu babu thomas8-Mar-06 21:17
Nibu babu thomas8-Mar-06 21:17 
GeneralRe: Immediate Dialog Close by Cancel Button Pin
toxcct8-Mar-06 21:19
toxcct8-Mar-06 21:19 
GeneralRe: Immediate Dialog Close by Cancel Button Pin
Nibu babu thomas8-Mar-06 21:38
Nibu babu thomas8-Mar-06 21:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.