C++ enhances the register keyword of C language

First of all, I recommend a github for learning C language/C++, sharing C language/C introduction, learning route, e-book recommendation and download, video recommendation, small projects, dry articles, written test interviews, C language/C++ specifications, open source projects, etc. .

Address: C language/C++ learning platform

//register keyword requests the compiler to put the variable a directly in the register, which is fast

//The variable modified by register cannot take the address in the c language, but the content is done in c++

/*

//1

Changes to the register keyword

The register keyword asks the "compiler" to store local variables in registers

Cannot get register variable address in C language

The register keyword is still supported in C++

The C++ compiler has its own optimization methods, and it is possible to optimize without using register

The address of register variable can be obtained in C++

//2

When the C++ compiler finds that the address of the register variable needs to be taken in the program, the declaration of the register variable becomes invalid.

//3

Early C compilers did not optimize the code, so register variables are a good addition.

*/

int main22()

{

         register int a = 0;

         printf("&a = %x\n", &a);

         system("pause");

         return 0;

}

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=324073225&siteId=291194637