Re: subclassing lists?

>  I wanted to model a line of points in a line class wich is a subclass of a
>  list. In the sence of C++

You can just hold a list of "struct point { double x, y; }" items or
something.  If you need to keep track of the last element and the
length of the list, just do this:

struct my_list {
    GList *head;
    GList *tail;
    int length;

There is no need for anything more complicated than that, as I see it :-)

>  I tried to follow the object oriented approach int C using the syntax from
>  GTK+ and GNOME. The problem was, that I canīt subclass the GList struct,
>  since it does not have a control element. GLists are used in the
>  form:

GLists are not part of the Gtk object system.  They are just part of
glib, which is a simple library of useful data structures and such.  I
don't know if it would be too useful to wrap them using GtkObjects;
they would just add overhead if anything else.


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