c/c++中的-->运算符
2012-09-05 20:53
176 查看
参考What is the name of this operator: “–>”?
c/c++中以下代码是合法的:
-->是一个合法的操作符,我打赌自认c/c++熟手的你们都不知道这个操作符。有人称它为goes to操作符,x-->0表示x向0趋近。
其实我在忽悠你们。 并且我相信有很多人对此把戏相当熟悉。没错,-->只是两个操作符恰好遇在了一起,他们是自减运算符--和大于比较运算符>:
类似的把戏还有:
原文地址:http://codemacro.com/2012/09/03/goes-to-operator/
written byKevin Lynx posted athttp://codemacro.com
c/c++中以下代码是合法的:
#include <stdio.h> int main() { int x = 10; while( x --> 0 ) // x goes to 0 { printf("%d ", x); } }
-->是一个合法的操作符,我打赌自认c/c++熟手的你们都不知道这个操作符。有人称它为goes to操作符,x-->0表示x向0趋近。
其实我在忽悠你们。 并且我相信有很多人对此把戏相当熟悉。没错,-->只是两个操作符恰好遇在了一起,他们是自减运算符--和大于比较运算符>:
while (x-- > 0) ...
类似的把戏还有:
while (x -- \ \ \ \ > 0) printf("%d ", x);
原文地址:http://codemacro.com/2012/09/03/goes-to-operator/
written byKevin Lynx posted athttp://codemacro.com
相关文章推荐
- 《C++第九周实验报告1-1》--------接第8周任务1,定义Complex类中的<<和>>运算符的重载,实现输入和输出
- C++类型转换运算符: static_cast<>,reinterpret_cast<>,dynamic_cast<>, const_cast<>
- 重学C++ 重载 流插入(<<)和流提取(>>)运算符
- C++箭头(->)运算符的重载
- C++中重载间接运算符(operator->())
- C++-->变量、常量与运算符
- C++ 重载操作符之一(指针运算符*,->)
- C/C++中的成员运算符(.)和指针运算符(->)
- 关于C++中操作符重载的疑问 :四个运算符=, ->, [], ()不可以重载为全局函数(友员函数)
- c++:成员指针运算符 .* 和 ->*
- 第九周C++上机报告(定义Complex类中的<<和>>运算符的重载)
- C++ 类成员访问运算符 -> 重载
- &lt;More Effective C++&gt;笔记--运算符
- C++解剖-> ||与&& 运算符认识
- C++类型转换运算符之const_cast<newtype>(expression)
- C++ 成员运算符(. 和 ->)
- C++的流插入运算符“<<”和流提取运算符“>>”的重载
- c++标准转换运算符 reinterpret_cast <new_type>
- 从零开始学C++之运算符重载(四):类型转换运算符、*运算符重载、->运算符重载、operator new 和 operator delete .
- C++规定有四个运算符 =, ->, [], ()不可以是全局域中的重载(即不能重载为友员函数)理解。