IonicWind Software

Aurora Compiler => General Discussion => Topic started by: Zen on December 22, 2006, 03:37:08 AM

Title: Calling Class Method From A Returned Class
Post by: Zen on December 22, 2006, 03:37:08 AM
I think thats an appropriate title for the topic :D...

I was just wondering, why I can't call a method from a class that is returned from another method or function without having to assign it to a variable first?

For example...

class A
{
    declare someMethod(),CWindow
}

A myClass = new(A,1);
myClass->someMethod().Create(.......);


If I want to do it, I have to first assign the return of someMethod to a new CWindow variable before I can assign the create method.

Is this something that will be fixed after or has it always been the intention to be like that?

Lewis
Title: Re: Calling Class Method From A Returned Class
Post by: Ionic Wind Support Team on December 22, 2006, 11:33:05 AM
You should be returning a pointer to the class, not a copy of the class as you are doing now.

declare someMethod(),CWindow *;

Then you can use:

myClass->someMethod()->Create(...);

As it was written you will run into some really odd problems and be posting again wondering why you can't close the window or something. When you declare a return of a class (or structure) type the compiler creates a copy of that class (or structure) on the heap so you can copy it to another variable outside of a method or subroutine.  Because variables delcare within a subroutine are located on the stack and don't exist when the subroutine exits.

Paul.