---C/C++ keywords--- asm, inline, register, virtual, volatile full solution

asm:

asm allows you to insert assembly language instructions directly into your code, various compilers allow inconsistent forms for this one instruction, for example:


    asm {
      instruction-sequence
    }

or 

    asm( instruction );
inline:

The inline keyword asks the compiler to expand a given function. It issues a call to the function that inserts the code. Functions with static variables, nested, switches, or recursion are not inlined. When a function declaration is enclosed within a class declaration, the compiler will attempt to automatically inline the function.
The keyword inline asks the compiler to expand space for a function, and it issues a call to the function to insert code. Functions with static data, loops, switches, or recursion are not given inlining. When a function declaration is contained within a When inside a class declaration, the compiler will try to automatically inline the function.

//语法:
inline int functionA( int i ) {
    ...
  }
register:

The keyword register asks the compiler to optimize the variables it defines, and usually this optimization is better than manual optimization.

virtual:

The keyword virtual can be used to create virtual functions, which are usually not considered limited by derived classes. But if the function is treated as a pure virtual function (indicated by =0), in this case it must be considered limited by derived classes.

//语法:
  virtual return-type name( parameter-list );
  virtual return-type name( parameter-list ) = 0;
volatile:

The keyword volatile is used when describing variables and prevents the compiler from optimizing those variables that are modified with volatile. Volatile is used where some variables can be changed in unexpected ways, such as throwing an interrupt. If these variables are not volatile, they may be different from the compiler. Conflicting optimizations performed.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325728876&siteId=291194637