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
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.