Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Object oriented programming in C [duplicate]

Tags:

c

oop

c89

Possible Duplicate:
Can you write object oriented code in C?

Hi, can someone point me to a tutorial explain me how OOP concepts can be implemented in ANSI C:

  • virtual functions
  • inheritance
  • best practice

A book about OOP programming ANSI C would be great too.

like image 364
drahnr Avatar asked Dec 01 '22 04:12

drahnr


2 Answers

Here is the link of a book on this topic: http://www.planetpdf.com/codecuts/pdfs/ooc.pdf (Object Oriented Programming in Ansi-C - exacty what you were looking for).

Good luck and have patience. Writing OOP in C is not an easy task, but can be somewhat rewarding if you like extreme things !

Another starting point will be to check GObject: http://library.gnome.org/devel/gobject/ and as @unwind said GTK is a good example of how to use OOP concepts in C. You can also take at GLib, is a nice library that will certainly make your C programming life a lot more easier, it is programmed in OOP manner, and as a plus is portable!

like image 142
Andrei Ciobanu Avatar answered Dec 04 '22 12:12

Andrei Ciobanu


  1. Objective-C isn't C - it's a different language.
  2. C isn't an object-oriented language. It's possible to do some OO-style stuff, but it's not what it's built for.
  3. Best practices in C are procedural.
like image 41
Skilldrick Avatar answered Dec 04 '22 13:12

Skilldrick