ตัวแปร¶
คำสงวน¶
alignas, alignof, and, and_eq, asm,
auto, bitand, bitor, bool, break,
case, catch, char, char16_t, char32_t,
class, compl, const, constexpr, const_cast,
continue, decltype, default, delete, do,
double, dynamic_cast, else, enum, explicit,
export, extern, false, float, for, friend,
goto, if, inline, int, long, mutable,
namespace, new, noexcept, not, not_eq,
nullptr, operator, or, or_eq, private,
protected, public, register, reinterpret_cast,
return, short, signed, sizeof, static,
static_assert, static_cast, struct, switch,
template, this, thread_local, throw, true,
try, typedef, typeid, typename, union, unsigned,
using, virtual, void, volatile, wchar_t, while,
xor, xor_eq
ชนิดข้อมูลพื้นฐาน¶
Group |
Type |
Remark |
---|---|---|
Characters |
char |
|
char16_t |
||
char32_t |
||
wchar_t |
||
Integers (signed) |
signed char |
|
signed short int |
||
signed int |
||
signed long int |
||
signed long long int |
||
Integers (unsigned) |
unsigned char |
|
unsigned short int |
||
unsigned int |
||
unsigned long int |
||
unsigned long long int |
||
Floating-point |
float |
|
double |
||
long double |
||
Boolean |
bool |
|
Void |
void |
|
Null pointer |
decltype(nullptr) |
ช่วงค่าข้อมูล¶
Type |
Macro |
Min Value |
Max Value |
Macro |
Remark |
---|---|---|---|---|---|
char |
CHAR_MIN |
-128 |
127 |
CHAR_MAX |
|
short char |
SCHAR_MIN |
-128 |
127 |
SCHAR_MAX |
|
unsigned char |
0 |
256 |
UCHAR_MAX |
||
short |
SHRT_MIN |
-32,768 |
32,767 |
SHRT_MAX |
|
unsigned short int |
0 |
65,535 |
USHRT_MAX |
||
int |
INT_MIN |
-2,147,483,648 |
2,147,483,647 |
INT_MAX |
|
unsigned int |
0 |
4,294,967,295 |
UINT_MAX |
||
long |
LONG_MIN |
-9,223,372,036,854,775,807 |
9,223,372,036,854,775,807 |
LONG_MAX |
|
unsigned long |
ULONG_MIN |
0 |
18,446,744,073,709,551,615 |
ULONG_MAX |
|
long long |
LLONG_MIN |
-9,223,372,036,854,775,807 |
9,223,372,036,854,775,807 |
LLONG_MAX |
|
unsigned long long |
0 |
18,446,744,073,709,551,615 |
ULLONG_MAX |
||
float |
FLT_MIN |
1.17549E-38 |
3.40282E+38 |
FLT_MAX |
|
double |
DBL_MIN |
2.22507E-308 |
1.79769E+308 |
DBL_MAX |
ตัวแปร¶
int a;
long long b;
float c;
double x, y, z;
การกำหนดค่า¶
int x = 0;
long y (0);
double x {0.0};
ประเภทข้อมูลอัตโนมัติ¶
int x = 0;
auto y = x; // int y;
decltype(x) z; // int z;
ข้อความ¶
การกำหนดค่า¶
string name = "Paul Phoenix";
string paul ("Paul Phoenix");
string p {"Paul Phoenix"};
ตัวอย่างโปรแกรม¶
1#include <bits/stdc++.h>
2
3using namespace std;
4
5int main() {
6 string name = "Paul Phoenix";
7
8 cout << name << endl;
9
10 return 0;
11}