Get an object as return value
Hi all.
I´m trying to get an object this way:
Object *myObject;
myObject = myFunction (parameters);
myFunction returns a Object type. It compile well, but when I execute, it crash.
How can I assign myObject to the return value?
I try to create a new instance: myObject = new Object(). But doesnt work.
Thanks!
MykoninePosted Oct 15, 2005, 5:35 PM
myObject* myFunction()
{
//some code
return someObjectPointer;
}
myObject* obj = myFunction();
That works. However, "some code" has to initialize an instance using "new myObject()", and you have to define the constructor "myObject()".