reference:language:increment
no way to compare when less than two revisions
差别
这里会显示出您选择的修订版和当前版本之间的差别。
前一修订版 | |||
— | reference:language:increment [2023/06/07 04:23] (当前版本) – 外部编辑 127.0.0.1 | ||
---|---|---|---|
行 1: | 行 1: | ||
+ | ====== ++ (increment) / -- (decrement) ====== | ||
+ | |||
+ | ===== 描述 ===== | ||
+ | |||
+ | 递增或递减一个变量 | ||
+ | ===== 语法 ===== | ||
+ | <code cpp> | ||
+ | x++; // | ||
+ | ++x; // x自增1返回x的新值 | ||
+ | |||
+ | x--; // x自减1返回x的旧值 | ||
+ | --x; // | ||
+ | </ | ||
+ | ===== 参数 ===== | ||
+ | |||
+ | x: int或long(可能是unsigned) | ||
+ | ===== 返回 ===== | ||
+ | |||
+ | 变量进行自增/ | ||
+ | ===== 例子 ===== | ||
+ | <code cpp> | ||
+ | x = 2; | ||
+ | y = ++x; // 现在x=3,y=3 | ||
+ | y = x--; // 现在x=2,y还是3 | ||
+ | </ | ||
+ | |||
reference/language/increment.txt · 最后更改: 2023/06/07 04:23 由 127.0.0.1