Eh, I don't have any specific advice, but the concept of an object and object oriented programming is distinct from classes. You can do OOP in any language. It's just the notion of having specific operations for a type of data and some level of private vs public access. In languages that aren't geared toward that, you need to do most of that stuff yourself.
As a small example regarding methods, in C++, say you had a class that you wanted to have a print method. You make class A and define A.print. Then you can do A a = A(123, 456); a.print()
.
In C, you use a struct to hold the data, and you define a free function print_A(struct A a)
, and then call print_A(a)
. Other than a small syntactic difference, there's little difference between writing a.print()
vs print_A(a)
.
You can arrange the definitions in the headers and C files so that you get something similar to private and public data and functions.
There are similar things for polymorphism, overloading, etc.
This post links to a book that goes into detail about how to really closely replicate C++ style programming in C. I personally don't think it's a good way to program in C, but I do think it's instructive. https://stackoverflow.com/questions/351733/how-would-one-write-object-oriented-code-in-c#351756
I haven't extensively used GTK, but I find that it is a nice C style implementation of object oriented programming, and maybe you could poke around with that to see how they do things.