>>>>>
常用类型举例:
using namespace std:
#define NUM "666666666"// 预定义
#define ADD(x, y) ((x) + (y));// 预定义
int num = 666;// 整数
int num1{ 666 }, num2{ 777 }, num3{ 888 };// 整数
double d_num = 66.66;// 小数
float f_num = 66.66;
char c_cha = 66.66;
short s_num = 66.66;
std::string str = "字符串";
std::int32_t s_int32 = 66.66;
std::int64_t s_int64 = 66.66;
std::int8_t s_int8 = 66.66;
const int i_count = 66;// 常量 整数
unsigned char u_char = 66.66;
// 类型转换。在()内填入你需要的类型
float c{ 550.25f };
int a1 = c;// 可能丢失数据
int a2 = (int)c;//
int a3 = static_cast<int> (c);// 静态转型
sizeof(a3)// 占用内存大小
// 枚举
enum e {
e_a = 0,
e_b = 1,
e_c,
}
变量的定义方式:
浮点数【重点】:
?类型转换:
?带符号的整数类型表:
不带符号的整数类型表:
?图片来源:易道云课堂
>>>>>
|