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条回答
唯我独甜
2楼-- · 2020-05-23 07:31

Define OOL. If you mean using classes etc, then C++ supports OO-style of programming among others. There's nothing that stops you from not using classes. Java OTOH, does not allow for but classes. (Yes, I do know Java supports FP.)

查看更多
该账号已被封号
3楼-- · 2020-05-23 07:34

No, it isn't. You can write a valid, well-coded, excellently-styled C++ program without using an object even once.

C++ supports object-oriented programming, but OO is not intrinsic to the language. In fact, the main function isn't a member of an object.

In smalltalk or Java, you can't tie your shoes (or write "Hello, world") without at least one class.

(Of course, one can argue about Java being a completely object-oriented language too, because its primitives (say, int) are not objects.)

查看更多
Emotional °昔
4楼-- · 2020-05-23 07:34

The big arguments people have against declaring C++ as "pure" OO is that it still requires at least one non-OO bit, main(), and that not everything is an object (int, long et al).

It also exposes the state of an object for manipulation without using the message-passing paradigm (public members). This breaks the encapsulation of objects.

Java, on the other hand, has main() as just a static method of a class so it's closer but it still has non-object things in it.

Smalltalk is the lingua franca normally held up as the purest of the pure, but I don't know enough about it to comment.

Me, I tend to leave those sort of arguments for the intelligentsia while I get on with developing code and delivering to my clients :-)

查看更多
何必那么认真
5楼-- · 2020-05-23 07:34

of course not!! It supports intrinsic data types.

查看更多
登录 后发表回答