The new() operator
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...
August 11, 2000 05:40 PM
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement