Advertisement

The new() operator

Started by August 11, 2000 05:29 PM
1 comment, last by Zygo_#2000 24 years, 4 months ago
Hello Guys... This might be a stupid question so be prepared . Alright, my problem is as follows. Lets say i have a class called CSprite. This class has a constructor taking 1 parameter. Normally i would do something like this: CSprite Sprite(parameter); But if i have to use the new() operator how would i then pass the parameter??? Something like: Sprite = new(CSprite(parameter)); or what??? Thanks...
Get rid of the outer parens.

Sprite = new CSprite(parameter);

should work.

When you have the parens there you''re saying that you want to use "placement new". Basically this is a way of saying that you''re already got a block of memory and you just want the object initialized in that place.

-Mike
Advertisement
Thank you very much...That worked...

This topic is closed to new replies.

Advertisement