03.基本关键字
约 388 字大约 1 分钟
1.数据类型
char
int
long
short
unsigned
signed
float
double
void
2.自定义数据类型
struct
union
enum
typedef
3.逻辑结构
if else
switch case default
do while for
continue break goto
4.类型修饰符
auto
register
static
const
extern
// 在C语言中,volatile关键字用于提示编译器某个变量的值可能会在程序的其他部分(例如硬件、中断服务例程或其他任务)中发生意外的改变
volatile
5.算术运算符
常量:
#define URl "http://xxxxx.xxx"
const long aa = 111L;
宏定义:
预编译
C++98/03关键字共63个
asm
基本语法:
asm("assembly code");
指定操作数:
asm("assembly code" : output : input : clobber);
扩展asm
asm("assembly code" : output : input : clobber : options);
嵌入汇编中的变量:
asm("assembly code" : : "r"(variable));
汇编模板:
asm volatile("assembly code" : : : "memory");
typedef
使用 typedef 为一个已有的类型取一个新的名字
1.定义新的类型别名:
typedef int Integer;
typedef float RealNumber;
2.结构体类型的简化:
typedef struct {
int x;
int y;
} Point;
3.指针类型的别名:
typedef char* String;
4.枚举类型的简化:
typedef enum {
MON,
TUE,
WED,
THU,
FRI
} Weekday;
* do
* if
* return
auto
* double
* inline
* short
typeid
* bool
dynamic_cast
* int
* signed
typename
break
* else
* long
* sizeof sizeof(变量名) 查询变量所占用的内存
union
* case
enum
mutable
* static
* unsigned
* catch
explicit
namespace
static_cast
* using
* char
export
* new
* struct
virtual
* class
* extern
operator
switch
* void
* const
* false
private
template
volatile
const_cast
* float
protected
* this
wchar_t
continue
* for
* public
* throw
* while
* default
friend
register
* true
* delete
* goto
reinterpret_cast
* try
C++11 关键字共73个 新增10个关键字:
alignas
alignof
char16_t
char32_t
constexpr
decltype
noexcept
nullptr
static_assert
thread_local