Why c ++ is not a fully object-oriented language?

Source: Internet
Author: User

1) The main function is not in any class. Because of this, it cannot be fully object-oriented. The other functions below can be solved.
2) The basic data type is not an object (from this point of view, Java is not completely object-oriented)
3) youyuan will damage Encapsulation
4) supports independent functions, data, that is, procedural programming

In fact, the so-called fully object-oriented language is a selling point that some people have come up with. It doesn't have much practical significance. Is it so powerful to include main into the class language?

C ++ supports three models: process-oriented, Object-based, and object-oriented.

Object-based means that we use object encapsulation technology to bind data and operations together, but it does not properly use object-oriented technologies such as polymorphism and inheritance for software design. Many people who used to develop C programs use object-oriented programming languages (such as C ++. Or they write process-oriented programs in an object-oriented language!

Purely object-oriented:

(1) Everything is an object. You can think of an object as a new type of variable. It stores data but requires it to operate on itself. Theoretically, all conceptual components can be put forward from the problem to be solved, and then expressed as an object in the program.
(2) A program is a combination of many objects. Through message transmission, each object knows what to do. To send a request to an object, you need to "send a message" to the object ". More specifically, you can think of a message as a call request, which calls a subroutine or function from the target object.
(3) Each object has its own storage space, which can accommodate other objects. Or, by encapsulating existing objects, you can create new objects. Therefore, although the object concept is very simple, the complexity of the program can be reached.
(4) Each object has a type. According to the syntax, each object is an "instance" of a "class ". Here, "class" is a synonym for "type. The most important feature of a class is "What messages can be sent to it ?".
(5) All objects of the same class can receive the same message. This is actually a different meaning, and you will soon be able to understand it. Because an object of the type "circle" also belongs to an object of the type "shape", a circle can fully receive shape messages. This means that the program code can run the "shape" in a unified manner, so that it can automatically control all objects that conform to the "shape" description, including the "circle ". This feature is called the "alternative" of objects and is one of the most important concepts of OOP.

Object-oriented is actually a natural extension of real-world models. Any entity in the real world can be seen as an object. Objects interact with each other through messages.

If the traditional procedural programming language is process-centric and algorithm-driven, the object-oriented programming language is object-centric and message-driven.

Expressed by formula:
Procedural programming language: program = Algorithm + data;
The object-oriented programming language is program = Object + message.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.