Is C++ an Object Oriented language?

2019-02-01 18:11发布

I have always heard that C++ is not Object Oriented but rather "C with Classes". So, when I mentioned to an interviewer that C++ was not really object oriented, he asked me why I didn't consider it an OO language. I haven't done any C++ since University, and I didn't have much of an answer. Is C++ Object Oriented or not? and why?

标签: c++ oop
18条回答
别忘想泡老子
2楼-- · 2019-02-01 18:37

Bah! The people who say C++ isn't object oriented are the same ones that would say Spam isn't food :-)

The OO "religious nutter" crowd will say that you can only have a true OO language if absolutely everything is an object. That's fine, they can sit in their ivory towers and believe what they want. Some of us have actual jobs to do.

Provided you use the object mindset, C++ (and even C if you use all sorts of tricks with function pointers within structures) is more than enough to be considered object oriented.

查看更多
够拽才男人
3楼-- · 2019-02-01 18:38

C++ is usually considered a "multi-paradigm" language. That is, you can use it for object-oriented, procedural, and even functional programming.

Those who would deny that C++ is OO generally have beef with the fact that the primitive types are not objects themselves. By this standard, Java would also not be considered OO.

It is certainly true that C++ isn't OO to the same extent as Smalltalk, Ruby, Self, etc. are, but it is definitely an effective OO language by most standards.

查看更多
Luminary・发光体
4楼-- · 2019-02-01 18:39

C++ is a multi-paradigm programming language supporting

programming styles. You can choose (and mix them) freely to meet the needs for your project.

查看更多
地球回转人心会变
5楼-- · 2019-02-01 18:40

Stroustrup, who designed C with classes, viz. the original implementation of the ISO C++ standard, answered the same question in ACM's OOPSLA '95. The paper's softcopy is available at http://www.stroustrup.com/oopsla.pdf.

查看更多
我命由我不由天
6楼-- · 2019-02-01 18:42

C++ is partially OO because the code can be written without the class and it has also multiple inheritance concept, i.e one child can have more than one parent.

查看更多
不美不萌又怎样
7楼-- · 2019-02-01 18:44

C++ is object oriented, because classes provide abstraction and inheritance and all that jazz. It's not always consider object oriented because code doesn't need to be object oriented. It's like saying Scheme isn't functional because it has set!.

查看更多
登录 后发表回答