[Gambas-user] INHERITS ?????
Benoit Minisini
gambas at ...1...
Sun Apr 11 23:13:48 CEST 2004
On Sunday 11 April 2004 22:52, Charlie Reinl wrote:
> Salut,
>
> saw in the mailinglist INHERITS .
>
> Want make 'INHERITS TableView'
>
> If I do so in a new Class called XTableView
> --- XTableView.class ---------------- beginning
> ' Gambas class file
> INHERITS TableView
>
> PUBLIC Name AS String
> PUBLIC SUB _new(sName AS String)
> Name = sName
> END
> --- XTableView.class ---------------- ending
>
> And call in FMain.class
>
> PRIVATE TableView2 AS Object
> ...
> PUBLIC SUB Form_Open()
> TableView2 = NEW XTableView(FMain) AS "TableView2"
> ...
> ...
> END
>
> I get a MsgBox 'Not enough arguments'
>
>
> What shall I do ?
>
> Amicalement
> Charlie
>
Ha ha! I must continue to explain how works the undocumented inheritance :-)
Contrary to all the object language I know, each class in the inheritance
hierarchy consumes the parameters passed to the constructor.
In your example, you have the following inheritance tree:
XTableView ---> TableView ---> Control
Control._new does not exist
TableView._new takes one parameter: the parent control.
XTableView._new takes one parameter: a name.
So NEW XTableView must take TWO parameters. The first will be sent to
XTableView._new(), the second to TableView._new(). But the TableView._new()
will be called first. This way, you are sure that TableView control exists
when you are in XTableView._new().
So you must do TableView2 = NEW XTableView("MyName", FMain) AS "TableView2"
I think I don't make a mistake in the parameters order. Tell me if I'm
right :-)
Regards,
--
Benoit Minisini
mailto:gambas at ...1...
More information about the User
mailing list