Re: [Vala] abstract method with random return value or parameters



Martin Kalbfuß píše v Čt 11. 02. 2010 v 02:11 +0100:
Hi,

I'm new to Vala, and not very experienced using objects.

[...]
 
The problem is the data member. Every data member of all the sub classes
has its own type(double, string ...). If I add it as a member of the sub
class, I need to cast the Item to the correct type before I can access
the data. But I don't see a way, make it accessible from the base class.
Any idea?

Thanks,



I'd say your best bet for this would be using GLib.Value as the
parameter type.
It is a kind of generic type, you can wrap anything in it. That comes
with some overhead of course.

The other possibility is to use a generic method, though I don't know
how usable that is at the moment.

Alternatively, if the item classes differ only in the content type,
you'd be better off making the Item class itself generic.

Attachment: signature.asc
Description: Toto je digitálně podepsaná část zprávy



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]