[Gambas-user] More on overriding native classes

Bruce bbruen at ...2308...
Mon Jun 18 15:29:45 CEST 2012


On Mon, 2012-06-18 at 22:39 +0930, Bruce wrote:

> Try this:
> Create a new command line project in the IDE.
> Add a new class "Application" with the following contents
> 
>         ' Gambas class file
>         
>         Create Static
>         Inherits Application
>         Export
>         
>         Static Public Hello As String = "Hello from South Australia"
>         
> Save and reload the project.
> In MMain.Main type the following:
> 
>         ?appl[Enter].he
> 
> ( see screenshot appended)
> Now that, to me, looks like we have successfully overridden the
> Application class, but look what happens when you run it.
> 

Let me rephrase that (sometimes the keyboard is quicker than the mind.)

Try this:
Create a new command line project in the IDE.
Add a new class "Application" with the following contents

       ' Gambas class file
       
       Create Static
       Inherits Application
       
       Static Public Hello As String = "Hello from South Australia"
        
Save and reload the project.
In MMain.Main type the following:

       ?appl[Enter].he

( see new! screenshot appended)
Now that, to me, looks like we have successfully overridden the
Application class, but look what happens when you run it.


What you should see is a very correct error message saying that Hello
is an unknown method in Application.  That is because it hasn't been exported.
But when I go back and export the class, then I get the Multiple Inheritance error.

B





More information about the User mailing list