C ++データ型
C ++データ型
変数の章で説明されているように、C ++の変数は指定されたデータ型である必要があります。
例
int myNum = 5;
// Integer (whole number)
float myFloatNum = 5.99;
// Floating point number
double myDoubleNum = 9.98; // Floating point number
char myLetter = 'D';
// Character
bool
myBoolean = true; // Boolean
string myText = "Hello";
// String
基本的なデータ型
データ型は、変数が格納する情報のサイズとタイプを指定します。
Data Type | Size | Description |
---|---|---|
int |
4 bytes | Stores whole numbers, without decimals |
float |
4 bytes | Stores fractional numbers, containing one or more decimals. Sufficient for storing 7 decimal digits |
double |
8 bytes | Stores fractional numbers, containing one or more decimals. Sufficient for storing 15 decimal digits |
boolean |
1 byte | Stores true or false values |
char |
1 byte | Stores a single character/letter/number, or ASCII values |
次の章で、個々のデータ型について詳しく学習します。