In C++, if you want to mimic malloc style behavior in
pure C++ way then write
Box *b = (Box *) operator new (sizeof (Box)); // statement 1
By this I mean the constructor of Box will not be invoked
as you expect with malloc. Note that this is NOT equivalent to
Box * b = new Box; // Statement 2
because doing that invokes the constructor.
Statment 1 is know as "operator new"!!
AND
Statment 2 is know as "new operator"!!
You have to match statement 1 by
operator delete(b); // does not invoke destructor
and statement 2 by
delete b; // invokes destructor
pure C++ way then write
Box *b = (Box *) operator new (sizeof (Box)); // statement 1
By this I mean the constructor of Box will not be invoked
as you expect with malloc. Note that this is NOT equivalent to
Box * b = new Box; // Statement 2
because doing that invokes the constructor.
Statment 1 is know as "operator new"!!
AND
Statment 2 is know as "new operator"!!
You have to match statement 1 by
operator delete(b); // does not invoke destructor
and statement 2 by
delete b; // invokes destructor
Comments
Carnival of Diasporas - no Armenians Allowed Filed under: Armenia , Diaspora , Technology - Posted by Katy on October 1st A few weeks ago I posted a link to the Carnival of Diasporas .
Hey, you have a great blog here! I'm definitely going to bookmark you!
I have a winning ad copy site/blog. It pretty much covers winning ad copy related stuff.
Come and check it out if you get time :-)
gclub casino