"Bowman, Michael W. \(MBOWMAN\)" <[EMAIL PROTECTED]> writes:
> I have a situation like the following:
> 
> void
> setParms(GtkOpenmapProj* proj, ...) {
>   ...
>   class->normalize_latitude(proj, ...);
> }
> 
> GtkOpenmapProj is a base class that has multiple sub-types. Each of the
> subtypes may
> override the normalize_latitude method of the GtkOpenmapProj class. However,
> I don't
> know which of the subtypes is passed into my function, just that its some
> sub-type of 
> GtkOpenmapProj. How do I find which type identifier to feed to
> gtk_type_class() so
> that I can obtain the class struct for the proper sub-type (and use the
> proper
> normalize_latitude function)? How does GTK+ handle polymorphism?

Just look at any example in GTK itself. You should not need the
subtype's class, just GtkOpenmapProjClass, which contains the
normalize_latitude function.

The whole point of virtual functions is you don't have to know the
type of the object, isn't it?

Usually people write a wrapper function:

void 
gtk_openmap_proj_normalize_latitude (GtkOpenmapProj *proj)
{
  GTK_OPENMAP_PROJ_GET_CLASS (proj)->normalize_latitude (proj);
}

Havoc
_______________________________________________
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list

Reply via email to