Is the C programming language object-oriented?

后端 未结 16 1196
我寻月下人不归
我寻月下人不归 2021-01-30 16:22

I was talking with a co-worker about C and C++ and he claimed that C is object-oriented, but I claimed that it was not. I know that you can do object-oriented-like things in C,

16条回答
  •  一整个雨季
    2021-01-30 17:15

    Though C itself was bulit as procedural language (it "thinks" in terms of procedure: You first execute function A then you pass the output to function B etc. it supports "out of the box" only functional program flow), It's possible to implement OOP over C (in OOP, the story is driven by Objects and their responsibilities rather than functions and their calling order). In fact, some early C++ implementations were translating the code to some C code and then building it. However, sometimes you must use C (for Embedded devices / GPU languages that don't support C++ etc). And you want OOP. I'd suggest you to check out COOP - my C OOP lightweight yet powerful framework for C object-oriented programming.

提交回复
热议问题