Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the data type of C++ correctly

Shulou Source: shulou.com Published: 2022-06-01 17:30:53 09月12日 Update

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

Tags: Character variable memory type space string data character type function style cantilever namely Boolean floating point syntax key keyword size quotation mark number Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Linux OPPO Reno MySQL Docker