C/C++速查表

整理的一份C/C++的速查表,平时整理下放到这里来,供方便查询。

C++ Operator Precedence

结合律 运算符 功能 用法
:: 全局作用域 ::name
:: 类作用域 class::name
:: 命名空间作用域 namespace::name
. 成员选择 object.member
-> 成员选择 pointer->member
[] 下标 expr[expr]
() 函数调用 name(expr_list)
() 类型构造 type(expr_list)
++ 后置递增运算 lvalue++
后置递减运算 lvalue–
typeid 类型ID typeid(type)
typeid 运行时类型ID typeid(expr)
explicit cast 类型转换 cast_name(expr)
++ 前置递增运算 ++lvalue
前置递减运算 –lvalue
~ 位求反 ~expr
! 逻辑非 !expr
- 一元负号 -expr
+ 一元正号 +expr
* 解引用 *expr
& 取地址 &lvalue
() 类型转换 (type)expr
sizeof 对象的大小 sizeof expr
sizeof 类型的大小 sizeof(expr)
sizeof 参数包的大小 sizeof…(name)
new 创建对象 new type
new[] 创建数组 new type[size]
delete 释放对象 delete expr
delete[] 释放数组 delete[] expr
noexcept 能否抛出异常 noexcept(expr)
->* 指向成员选择的指针 ptr->*ptr_to_member
.* 指向成员选择的指针 obj.*ptr_to_member
* 乘法 expr*expr
/ 除法 expr/expr
% 取模(取余) expr%expr
+ 加法 expr+expr
- 减法 expr-expr
<< 向左移位 expr<<expr
>> 向右移位 expr>>expr
< 小于 expr<expr
<= 小于等于 expr<=expr
> 大于 expr>expr
>= 大于等于 expr==expr
== 相等 expr>=expr
!= 不相等 expr!=expr
& 位与 expr&expr
^ 位异或 expr^expr
¦ 位或 expr ¦ expr
&& 逻辑与 expr && expr
¦¦ 逻辑或 expr ¦¦ expr
?: 条件(三目运算符) expr?exper:expr
= 赋值 lvalue=expr
*/,/=,%=,+=,-=,<<=,>>=,&=, ¦=,^= 复合赋值 lvalue+=expr等
throw 抛出异常 throw expr
, 逗号运算符 expr,expr

C++ Keywords

alignas (since C++11) else requires (concepts TS)
alignof (since C++11) enum return
and explicit short
and_eq export(1) signed
asm extern sizeof
auto(1) false static
bitand float static_assert (since C++11)
bitor for static_cast
bool friend struct
break goto switch
case if template
catch inline this
char int thread_local (since C++11)
char16_t (since C++11) long throw
char32_t (since C++11) mutable true
class namespace try
compl new typedef
concept (concepts TS) noexcept (since C++11) typeid
const not typename
constexpr (since C++11) not_eq union
const_cast nullptr (since C++11) unsigned
continue operator using(1)
decltype (since C++11) or virtual
default(1) or_eq void
delete(1) private volatile
do protected wchar_t
double public while
dynamic_cast register xor
reinterpret_cast xor_eq

Conversion Specifiers in C

Conversion Output Specification
%a Floating-point number, hexadecimal digits and p-notation (C99/C11).
%A Floating-point number, hexadecimal digits and P-notation (C99/C11). Exploring and Exploiting printf() and scanf()
%c Single character.
%d Signed decimal integer.
%e Floating-point number, e-notation.
%E Floating-point number, e-notation.
%f Floating-point number, decimal notation.
%g Use %f or %e , depending on the value. The %e style is used if the exponent is less than −4 or greater than or equal to the precision.
%G Use %f or %E , depending on the value. The %E style is used if the exponent is less than −4 or greater than or equal to the precision.
%i Signed decimal integer (same as
%o Unsigned octal integer.
%p A pointer.
%s Character string.
%u Unsigned decimal integer.
%x Unsigned hexadecimal integer, using hex digits 0f .
%X Unsigned hexadecimal integer, using hex digits 0F .
%% Prints a percent sign.
全文完,若有不足之处请评论指正。

微信扫描二维码,关注我的公众号。

本文标题:C/C++速查表
文章作者:查利鹏
发布时间:2015年01月15日 23时56分
本文字数:本文一共有2.7k字
原始链接:https://imzlp.com/posts/14660/
许可协议: CC BY-NC-SA 4.0
文章禁止全文转载,摘要转发请保留原文链接及作者信息,谢谢!
您的捐赠将鼓励我继续创作!