What is the greatest difficulty in learning the C ++ programming language?

Source: Internet
Author: User
What is the greatest difficulty in learning the C ++ programming language?-General Linux technology-Linux programming and kernel information. For more information, see the following. Difficulty

"C ++ is a difficult language to learn and use. The difficulty of C ++ learning lies in the fact that there are too many "screens" of the language itself, and the other lies in "paradigm shift" (the transfer of thinking models ).

In traditional languages such as C, Pascal, Basic, and Fortran..., apart from their slightly different appearances, basically all calls are called by function, which is similar and easy to understand. The actions you Want to do are clearly visible in the code. What you don't see, that is, the compiler adds a small segment of code (prologue and epilogue) used to process the stack for your function. Basically, this small segment of code is used for housekeeping, it doesn't matter if you don't see it. It doesn't affect your thinking about program logic.

C ++ is different. C ++ has too many actions that are closely related to the program logic, and the compiler adds them to us. In other words, the C ++ compiler "encodes" us ". If you do not know this section, learning C ++ is like watching flowers in fog, fog is not fog, and flowers are not flowers.

What code does the compiler add to our C ++ program? A lot! When an object is born, the ctor operator is aroused, and the dtor is aroused when the object is dead. This is the result of code addition. Set vtpr and vtbl in ctor, which is also the result of Code adding. A memory block cookie is generated when a new object is created. When a new object array is created, an internal structure record object size and class ctor... are generated, which are all behind the scenes. It can be said that all the actions that cannot be seen in the Code but must be completed related to the program logic are all the results of the code added by the C ++ compiler.

When "inheritance" occurs, the entire situation becomes a little complicated. "Multi-inheritance" is more complex, and "virtual inheritance" is more complex.

The Theme behind the scenes can be categorized as the so-called C ++ object model (object model ). If you do not know these underlying mechanisms, you can simply stick back the rules "make destructors virtual in base classes" or "never treat arrays polymorphically", but do not understand the principles. Lin Yutang said: "Not brilliant ". Only know how, not know why.

Difficulty 2

The second learning difficulty of C ++ is "paradigm shift" (Transfer of thinking mode ). Do not design your own classes. Simply using others' classes is a transfer of thinking and behavior patterns. MFC (or OWL or VCL) programmer must be able to understand and understand what it means.

What is the relationship between your code and the framework using the so-called application framework (a large-scale, cohesive class library with object-oriented public infrastructure? What are the meanings and values of a bunch of modifiable virtual functions provided by framework? Why can the various beautiful properties and algorithms designed by the framework be applied to our own class types? When the framework is designed, we do not know its existence. This is the power of polymorphism in object orientation.

The C ++ object model mentioned earlier belongs to the lower layer of programming. The thought mode transfer mentioned here is the high-level aspect of programming. We can give full play to the power of new thinking models, such as object-oriented polymorphism (multi-type) and generalization (generic ). If you do not use these two features, it is equivalent to entering C ++ Baoshan, but empty-handed.

Reverse refining and cyclical fluctuation

Imagine that C ++ is a tool used to solve program problems. If it is sharp, it must be tempered for many times, in between hot and cold.

After learning the C ++ syntax (syntax), you should try to use polymorphism as soon as possible (roughly the use of virtual functions ). When we have the ability to take control of the overall situation of OOP, but we are not very clear about many small details of C ++, that is, the time to repeat the C ++ object model.

Growth is a reverse shock between the higher order (polymorphism) and the lower order (object model) to be able to shock to a higher level, rather than mediocre to the middle order (C ++ syntax) A beach of dead water.
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.