Is C++ completely object oriented language?

2020-05-23 06:38发布

I read about small talk being completely object oriented.. is C++ also completely object oriented? if no.. then why so??

标签: c++ oop
10条回答
倾城 Initia
2楼-- · 2020-05-23 07:13

C++ is not a pure object oriented language, and as already mentioned nothing forces you to use OOP concepts in C++. C++ is what you call a hybrid object oriented language, as it's based on C which is purely a procedural language.

Examples of pure object oriented languages are C# and JAVA.

查看更多
虎瘦雄心在
3楼-- · 2020-05-23 07:14

The short answer is no - C++ is not entirely OO language. You can write "not exactly" OOP using C++ even without resorting to using the C subset. One such example is your main method - which is not contained in any class.

The main reason is the fact that C++ originated from C - when Stroustrup created the language he was aiming to create a new version of C (with classes). in fact he have tried to submit his creation as the new flavor of C (C84).

查看更多
Juvenile、少年°
4楼-- · 2020-05-23 07:19

The reason why C++ is not a OOP language is mainly because it is missing the concept of encapsulation. You can't define an interface/contract to your object because of the pointers which give you total control on everything.

查看更多
对你真心纯属浪费
5楼-- · 2020-05-23 07:24

C++ is nothing but "C with classes". I can still write a C program and save it as .cpp file. So, Proof by implication says "C++ is not a purely object oriented language."

查看更多
做个烂人
6楼-- · 2020-05-23 07:25

C++ contains a 'C' dialect as a subset, permitting a purely procedural style of code.

查看更多
聊天终结者
7楼-- · 2020-05-23 07:28

No, it is not a purely object oriented language. In particular primitive datatypes in C++ have rules that are frequently different from datatypes that aren't primitive. Additionally it is possible to have functions that are not associated with any datatype at all. There are a myriad of other ways in which C++ is not a pure object oriented language, but those are two of the biggest reasons.

Neither Java nor C# are pure object oriented languages either because they have primitive datatypes that do not obey the same semantics as 'object' datatypes.

查看更多
登录 后发表回答