Re: GObject Interface vs Pure Virtual Class



On Sat, May 12, 2007 at 02:42:50PM +0800, Kuang-Chun Cheng wrote:
>    On 5/12/07, Jean Br*fort <[1]jean brefort normalesup org> wrote:
....
> 
>      A GObject class can inherit from only one parent (which might be
>      virtual), but you can add as many Interfaces as you like. It is somewhat
>      similar to multiple inheritance in C++ (more like the D language
>      actually).
> 
>    Hi Jean,
> 
>    That's new to me ... I did not catch up this from GObject Ref. Manual ...
>    Thanks.
> 
>    KC

It's also important to note that GTK+ Interfaces cannot directly
implement any functionality, unlike C++ classes.  They only specify the
set of (rigid) "prototypes" that *must* be fully implemented by the
implementing class.  Interfaces also define a "type" which the
implementing class must be cast-to in order to call the interface
methods.  In C++, an analogous situation would be implementing a pure
virtual class (containing *only* pure virtual methods), which can be
used in single or multiple inheritance.  The GTK+ inheritance model is
much more like Java than C++; with only single inheritance allowed, but
no limit on the number of Interfaces which may be implemented.  (much
better than C++ imho.)  I recommend you read about Java interfaces.

- Ana



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