Item 1: Treat C + + as a series of languages effective C + + notes

Source: Internet
Author: User

Item 1:view C + + as a federation of Languages

At first, C + + was just the C language plus some object-oriented features, so C + + 's original was "C with Classes". Now C + + has matured to become a multi-paradigm programming language (Multiparadigm programming language). It also supports programs, object-oriented, functional, generic programming, and meta-programming.

The flexibility of C + + makes it not uniform on many issues, but depends on the specific programming paradigm and the design intent of the current architecture. In this case, we'd better think of C + + as a series of programming languages rather than a specific programming language.

C + + has four primary sub-languages:

    • C. C + + is design-based, you can use only C in C + + that part of the syntax. At this point you will see that your program reflects exactly the characteristics of C: No templates, no exceptions, no overloads.
    • object-oriented C + +. Object-oriented programming is also the original design of C + +: The virtual function of construction and destruction, encapsulation and inheritance, polymorphism and dynamic binding.
    • Template C + +. This is the generic programming part of C + +, which is rarely covered by most programmers, but templates are still very handy in many cases. In addition, template meta-programming (metaprogramming) is also an emerging programming paradigm, albeit a bit non-mainstream.
    • Stl. This is a special template library whose containers, iterators, and algorithms are elegantly combined, but you need to follow its programming conventions when you use them. Of course you can also build a template library based on other ideas.

In short, C + + is not a single language, it has many different sets of rules. Thus C + + can be considered as a collection of four primary sub-languages, each with its own programming conventions.

The practice of C + + programming is not a matter of dust, but depends on which part of the C + + language you use. For example, in a C-based program design, the simultaneous value of the basic type parameter is more efficient than a pass-through reference. However, when you touch object-oriented C + + you will find that passing constant pointers is a better choice. But if you hit the STL again, and the iterators and function objects are all based on the C language pointers, then back to the original rule: the value of the pass is better than the reference.

Unless noted, this blog article is original, reproduced please link to the form of this article address: http://harttle.com/2015/07/19/effective-cpp-1.html

Copyright NOTICE: This article is for bloggers original articles, reproduced please attach the original link.

Item 1: Treat C + + as a series of languages effective C + + notes

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.