Hi i want to do the next
instead of
MyClass object;
function_x (object);
i want to
function_x ( new object );
so what will be the structure of the MyClass to be able to do that ..
if i just compiled it , it gives me a compile time error
answer function_x (MyClass() )
New Edit thanks for the quick answers.. i did ask the wrong Question i should have asked how
temporary variables created in C++ and the answer
newis called on classes, not objects. And it returns a pointer, so unlessfunction_xaccepts a pointer, this is impossible.You can do this though:
Note a few things about this:
MyClassis called when it’s createdfunction_ymust keep the pointer in some accessible place to avoid a memory leakIs this what you need, or something else?