GObject inheritance (simple example)

I’m trying to build a simple example of GObject usage. I came with the following code

The code do not compile because it complains about invalid type argument.

What can I do to fix the code?

Besides that, any other tips are welcome.


For the first error:
The way to chain up to the parent class in GObject is to get the parent class and call the vfunc, i.e. PET_BASE_CLASS (pet_dog_parent_class)->print(PET_BASE (self)); (but of course that entire function is useless in this case since it just chains up and does nothing else).

The second error:
You’re assigning a function that takes a PetDog * argument to a function pointer that expects a Pet Base *) argument. Just change the function prototype and if you need a PetDog* inside the function, cast as appropriate.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.