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 |
다음 장에서 개별 데이터 유형에 대해 자세히 알아볼 것입니다.