What is C ++ hosting?

Source: Internet
Author: User

The C ++ programming language has been developing for more than 20 years. The following describes the basic concepts and composition of this programming language. After learning about the content, we will enter the theme of the near body, that is, what is C ++ hosting for you?

  • Skills related to C ++ eof () Functions
  • C ++ resource management application skills
  • C ++ declares the correct method of application
  • How can C ++ inline functions help us?
  • C ++ smart pointer Application Experience

The term C ++ is usually read as "C ++" in mainland China's programmer circles, while Western programmers generally read as "C plus" and "CPP ". It is a widely used computer programming language. C ++ is a common programming language that checks static data types and supports multiple programming paradigms. It supports various programming styles such as process-based programming, data abstraction, object-oriented programming, and generic programming, such as creating icons.

According to the description in Article 1 of the third edition of Objective C ++, C ++ is composed of the following four sub-languages:

1. Sub-Language C. C ++ supports almost all the functions of C language. It is syntactically only slightly different from C language (for example, the left and right values of parentheses expressions. For details, see the C ++ standard document ).

2. Object-oriented C ++. C ++ is first known as an object-oriented language. This feature is not described here.

3. Generic programming language. C ++ is powerful but easy to get out of control) the template function enables it to complete a lot of work during the compilation period, thus greatly improving the efficiency during the runtime.

4. STLC ++ standard template library ). With the continuous development of STL, it has gradually become an indispensable part of C ++ program design, and its efficiency may be lower than that of general naive code, however, its security and standardization make it very popular.

To answer this question, you must first understand what is Managed ). Hosting is. NET is a new programming concept integrated with the general language runtime (CLR). Therefore, we can regard "hosting" as ".. NET ". So what is "general language runtime "? The general language runtime is the execution lead of. NET Framework applications. It provides many services, including code management (load and execution), type security verification, metadata (advanced type information) Access, memory management for management objects, and code management, interaction and operability of COM objects and pre-generated DLLs (non-managed code and data), and support for developers' services.

That is to say, the use of C ++ hosting means that our code can be managed by CLR and can develop new features such as automatic garbage collection and inter-program access.. NET Framework application.

The C ++ application triggered by the concept of hosting consists of three parts: hosting code, hosting data, and hosting.

(1) managed code: the. Net environment provides many core RUNTIME services, such as exception handling and security policies. To be able to use these services, you must provide some information code (metadata) to the runtime environment, which is the managed code. All C # and VB. NET, JScript. NET is hosted by default, but Visual C ++ is not hosted by default. You must use the command line option (/CLR) in the compiler to generate managed code.

(2) managed data: managed data is closely related to managed code. Managed Data is the data allocated and released by the garbage collector running in the public language. By default, C #, Visual Basic, and JScript. NET data are hosted data. However, by using special keywords, C # data can be labeled as unmanaged data. Visual C ++ data is not hosted by default, even when the/CLR switch is used.

(3) Hosting class: Although Visual C ++ data is not hosted by default, when using C ++ to host extensions, you can use the "_ gc" keyword to mark the class as a Managed class. As shown in the name, it indicates that the memory of the class instance is managed by the garbage collector. In addition, a Managed class can also be. NET Framework members, which can bring about the benefit that it can correctly perform operations with classes written in other languages, for example, hosted C ++ classes can be inherited from Visual Basic classes. But there are also some restrictions, such as hosting classes can only inherit from one base class. It should be noted that in C ++ managed applications, both managed classes and unmanaged classes can be used. The unmanaged class here is not a standard C ++ class, but a class hosting the _ nogc keyword in the C ++ language.

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.