Search code examples
ooplanguage-agnosticlanguage-featuresprocedural-programming

Is it possible to implement all 4 principles of Object Oriented Programming using only procedures and global variables?


This is a question that has haunted me for a long time now.

Is it possible to implement OOP principles like Polymorphism and Inheritance in a non-OO language like C using only procedures and global variables? Do we need special treatment from lower level abstractions for that?

Does this question makes any sense at all?!


Solution

  • Of course, its possible to use a language like C in an OO manner. Polymorphism can be emulated with pointers to functions (but don't expect to get easy manageable code this way). Perhaps this discussion

    http://ootips.org/oop-in-c.html

    will help you to get some more insights.