This Application Note describes simple and efficient implementation of main Object-Oriented concepts of encapsulation, single inheritance and polymorphism in portable ISO-compliant C. This implementation is specifically suitable for real-time embedded systems.
The AppNote is accompanied with actual code that you can compile and execute on any desktop computer (running Windows, Linux, or MacOS).
Here is the code structure:
OOP-in-C
¦
¦ AN_OOP_in_C.pdf
¦ LICENSE
¦ README.md
¦
+---encapsulation
¦ main.c
¦ make.bat
¦ oop_in_c.exe
¦ shape.c
¦ shape.h
¦
+---inheritance
¦ main.c
¦ make.bat
¦ oop_in_c.exe
¦ rect.c
¦ rect.h
¦ shape.c
¦ shape.h
¦
+---polymorphism
circle.c
circle.h
main.c
make.bat
oop_in_c.exe
rect.c
rect.h
shape.c
shape.h
The concepts of OOP in C have been explained in a series of videos: