C++ new operator

  • maths_fan
  • Newbie
  • Newbie
  • maths_fan
  • Posts: 5

Post 3+ Months Ago

Just want to ask, maybe someone knows about overloading "new operator" and "operator new". How to overload "operator new", if it's possible? For what to overload the "new operator" (some examples, if possible). Thanks in advance.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • _Leo_
  • Proficient
  • Proficient
  • User avatar
  • Posts: 279
  • Loc: Buenos Aires, Argentina

Post 3+ Months Ago

As far as I know, you won't overload the new operator, you will just overload the constructor method.

class MyClass {

function MyClass();
function MyClass(UINT iParam);

}
  • maths_fan
  • Newbie
  • Newbie
  • maths_fan
  • Posts: 5

Post 3+ Months Ago

It's a pity, that you don't know :) but it's possible "to overload" operators:

void* operator new(size_t size)
{
// what you want to do 8)
}

There is also "operator new", which can't be overloaded (as I could find out). It's the operator, which only allocates memory (doesn't call any constructor) and "new operator" also allocates memory by using "operator new" and then calles the constructor :shock:

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 127 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.