Is the C programming language object-oriented?

后端 未结 16 1166
我寻月下人不归
我寻月下人不归 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:05

    C is not an O-O language under any definition of "O-O" and "language".

    It is quite easy to use C as the implementation language for a component that gives an O-O API to its clients. The X Windows system is essentially a single-inheritance O-O system when viewed from its API, but a whole mess of C when viewing its implementation.

    0 讨论(0)
  • 2021-01-30 17:05

    The confusion may be that C can be used to implement object oriented concepts like polymorphism, encapsulation, etc. which may lead your friend to believe that C is object oriented. The problem is that to be considered an object oriented programming language, these features would need to be built into the language. Which they are not.

    0 讨论(0)
  • 2021-01-30 17:09

    Real programmers can write object-oriented code in ANY language.

    But no, C is not an 'object-oriented' language. It has no concept of classes, objects, polymorphism, inheritance.

    0 讨论(0)
  • 2021-01-30 17:13

    C is not Object Oriented.

    C does not orient to objects.

    C++ does.

    0 讨论(0)
  • 2021-01-30 17:15

    If by "is C object oriented?" you mean "is C designed with facilities specifically to support object oriented programming?" then, no, C is clearly not object oriented.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题