How to use the data type of C++ correctly
This article mainly explains "how to correctly use the data types of C++", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn how to use the data types of C++ correctly.
Preface
Unlike python, C++ must specify a type when creating a variable in order to allocate an appropriate memory space to the variable.
1 integer type
Function: integer variables represent data of integer types
There are four data types of integers (the most commonly used is int), and the difference lies in the amount of memory occupied:
# includeusing namespace std;int main () {/ / integer / / 1. Short integer short num1 = 32768; / / 2. Integer int num2 = 10; / / 3. Long integer long num3 = 10; / / 4. Long integer long long num4 = 10; cout