Saturday, October 01, 2005

Operator new

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

15 comments:

Anonymous said...

What a nice blog you have! You can be sure that I'll be coming back!

Check my golfing blog!

Anonymous said...

October 2005
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 :-)

usb cable nokia 322023e said...

Sensational blog. I took pleasure in the site and I
will go back! Surfing online for blogs like this one
is worth my time.
Come as you are and look at my faxless cash advance blog.

Free Cash Till Payday Loan said...

Astonshing blog. I relished in the site and you
know I will be going to it again! Surfing the internet
hepls me to find blogs that arfe just as good.
It may look like it was hard work, but my 1800contacts coupon blog was simple.

delightfully-different said...

Captivate blog. I surf the web for blogs this
nature.The site are wonderful and will be returned to
again!
Look who checking out my 1800contacts coupon code blog?

dat-girl said...

Unusual blog. I liked the site its from so much I
have to visit it again! I surf the web for blogs like
yours in my spare time.
Want to see top notch work, peep my 1800contacts coupon codes blog site for the bomb work!

Instant Cash Loan Till Payday Com said...

Nice blog. I seen the site and I adored the work,
that I want to visit it more each day! I like
searching for blogs that have the same content like
this one!
Please discover my 1800contacts web coupon code blog.

lightly-blended said...

Hype blog. And I admire your site and plan on
returning to it! When I web surf it always helps me to
find great blogs.
Hey why don't you peep my 1800contacts coupon code blog site.

florida mortgage lenderf7 said...

Great blog. I'm always finding blog like yours. It
got my attention and I will go to the site again!
Please proceed to my 1800contacts web coupon code blog when you find the time.

final fantasy 10 musicd said...

Exciting blog. Your site was amazing and will be
back again! I never get tired of looking for blogs
just like this one.
Please come by and see my 1800contacts coupon codes blog.

quick cash advance loan1c1 said...

Great blog. I'm always finding blog like yours. It
got my attention and I will go to the site again!
Look into my 1800contacts coupon blog.

die4-u said...

Excellent blog.  I go though the web in search of
blogs like this one. Its so good, that I plan on
returning to its site!
Go and click my coupon codes 1800contacts blog.

job opportunitya said...

Great blog. I surf the web looking for blogs like
this. Your site was on point and will be back again!
My plastic surgery illinois blog, is something you need to peep out!

job opportunitya said...

I surf the web looking for blogs like this one.
Your site was on point and will be back again! Awesome
blog.
I wish I was like you, but I'll go and peep your 1800contacts web coupon code blog.

manho valentine said...

Thanks you for sharing


gclub casino