constructors and using "new"

Hi -

I'm a reasonably seasoned C programmer, but very new to C++ (taking a class in C++ right now).

My current assignment calls for creating heap space for new objects by using the "new" operator. How can I get the desired constructor to be called when creating objects in this manner?

Thank you.
new Object(/*whatever you would normally put in your constructor*/);
I would suggest something like this:
1
2
MyClass* object; // your class, creates pointer
object=new MyClass;  // makes the pointer an object, you can now use it and it will call the constructor (if any) at this point 


EDIT: I had not noticed firedraco posted
Last edited on
Outstanding. I guess I should have been able to figure that out myself, but thanks.
Topic archived. No new replies allowed.