April 26, 2024, 11:45:55 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Calling Class Method From A Returned Class

Started by Zen, December 22, 2006, 03:37:08 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Zen

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

Ionic Wind Support Team

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.



Ionic Wind Support Team