Is the C programming language object-oriented?

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

    Unless your friend was talking about Objective C (an OO superset of C) then no, C isn't an OO language. You can implement OO concepts using C (that's what the old cfront C++ compiler did, it translated C++ into C) but that doesn't make C an OO language as it doesn't specifically offer support for standard OO techniques like polymorphism or encapsulation.

    Yes, you can write software OO style in C, especially with liberal (ab-)use of macros but as someone who has seen the results of some of those attempts, I'd strongly suggest to use a better suited language.

提交回复
热议问题