C++ provides a large number of integers for you to choose which type to use. In general, int is set to the most "natural" length of the target computer. Natural size refers to the most effective length of computer processing. If there is no compelling reason to choose another type, you should use int.
Let's see why other types can be used: if the value represented by a variable cannot be negative, such as the number of words in a document, you can use unsigned type, so that the variable can represent a larger value.
If you know that the integer value that a variable may represent is greater than the maximum possible value of 16-bit integer, use long. This should be done even if the int on the system is 32 bits. In this way, when the program is transplanted to the 16 bit system, the program will not suddenly fail to work normally.
. Short is smaller than int, so using short can save memory. Short is usually only needed when there is a large integer array (an array is a data structure that continuously stores multiple values of the same type in memory). If saving memory is important, you should use short instead of int, even if they are the same length. For example, suppose you want to migrate a program from a DOS PC system with an int of 16 bits to a Windows XP system with an int of 32 bits, then the amount of memory used to store int arrays will double, but short arrays will not be affected.