Register: If some variables are used frequently, it takes less time to access the value of the variable, you can put the value of the local variable in the register of the CPU, take the participation operation directly from the register when needed, do not have to go to the memory to access. This can improve execution efficiency because the registers are accessed much faster than the memory access speed. This variable is called a "register variable" withRegisterMake a statement. Description: (1Only local auto variables and formal parameters can be used as register variables, and others such as global variables are not allowed. (2There is a limit to the number of registers in a computer system, and you cannot define any number of register variables. (3A local static variable cannot be defined as a register variable.Const: (1) defines theConstConstant, with immutability. (2) facilitates the detection of types, eliminating some unsafe hazards. (3Protect the item from being modified to prevent accidental changes that affect the safety of the program. (4Improve the robustness of the code, grammatical logic more rigorous. (5)ConstTypes of variables save space when the program runs with only one copy. (6The compiler is usually not a normalConstConstants allocate memory space, but instead save them in the symbol table, making them a compile-time constant, without the storage and read memory operations, improving efficiency.Static: (1Global static variable or global static function: Protecting the variable and the static function is valid within its scope and cannot be used outside of the scope of this scope. (2Global static variables are stored in the global data area, and the initialized system gives it default initial values. Local static variables are also stored in the global data area, scoped only to the scope in which it belongs, but the life cycle has the end of the project. (3A static member variable only has one copy and belongs to that class and not any member variable, and static member functions can only use static member variables because they do not belong to any one object and belong to this class only.volatile: If a basic variable isvolatileModification, is to tell the compiler not to optimize the variable, meaning that every time the value is accessed directly from the memory operation, which requires that the variable is stored in the memory of the real strict requirements of variables, it can be declared asvolatileType, which is used more in multi-threading.typedef: (1Defines a type of alias, rather than a simple macro substitution, that can be used as multiple objects that declare a pointer type at the same time. Such as:Char*pa,pb//declares a pointer variable and a character variable. typedef Char* Char_ptr char_ptr PA,PBTwo pointer variables are declared here. (2)typedef structNode {}node;//Used more in the old C language to re-alias the struct. (3) withtypedefTo define platform-independent types. For example, define a Val floating-point type that can represent a high-precision range on the target platform. TypdefDoubleVAL; But it's not supported on another platformDoubleType, we can do this on this platformtypedef floatVAL; This allows you to define your own appropriate type across the platform without having to modify a large amount of code. (4A simple or easy-to-tag name for a complex statement. Define: (1The variable is only replaced by the original mode in the preprocessing phase, and does not do any type detection, mainly defining variables or defining functions. (2Use IFNDEF,DEFINE,ENDIF to prevent duplicate references.
静态库: 1.浪费空间,每个程序都有一份。 2.如果有一个地方修改了则需要重新的编译加载。 3.执行速度快,不需要动态加载。 动态库: 1.动态库只是导出一个动态表,在程序运行的时候他动态加载。 2.多个程序共享 3.运行时加载,可以很容易的修改,就是打补丁。 4.运行的动态加载会花费一定的时间。}
#include <iostream>#include <math.h>using namespace STD;//Hill sort. voidShell (intA[],intN) {//Increment value. //x=log10 (n) this function exists. //(log (a) (b)) =lg (b)/LG (a) or ln (b)/ln (a). intm = n;//Save a copy of length. intLen =log10(n)/(log10(2))+3;int*b =New int[Len];intK =0;intTemp while(N >1) {b[k++] = (N/2+1);if(N/2==1) Break; n = (n/2) +1; } b[k++] =1; for(inti =0; I < K; ++i) {temp = B[i]; for(intj =0; J < M-temp; ++J) {if(A[j]>a[j + temp]) {A[j] ^= a[j + temp]; A[j + temp] ^= a[j]; A[J] ^= a[j + temp]; } } }}intMain () {intA[] = {9,8,7,6,5,4,3,2,1,4,5,6,0,1,2,3,5534,5,542,3,4,6,7,8,6,123};//int a[] = {5, 4, 3, 2, 1};Shell (A,sizeof(a)/sizeof(int)); for(inti =0; I <sizeof(a)/sizeof(int); i++) {cout<< A[i] <<" "; }cout<< Endl;return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
C + + keywords Big summary