Re: GInterface on a per-instance-basis



On Thu, 2003-09-04 at 13:32, Ronald Bultje wrote:
> Hey,
> 
> I need an object that implements an interface in certain circumstances,
> but not all (but it has to be the same object!). In these other cases,
> the interface cast should return NULL (or something similar that tells
> me that it doesn't implement this interface).

It sounds like interfaces aren't the direct answer to the problem you're
trying to solve, then.

If you need to compute things dynamically, that's what object methods
are for.  You can have an interface that has a single method like

gboolean ::supports_foo ();

and then if that returns true, then cast the object to the interface you
want.




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