桑海

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
 1 #include<iostream>
 2 using namespace std;
 3 
 4 int main()
 5 {
 6     //cout << 3+5 << endl;
 7     cout << (1>2?3+5:"hello") << endl;
 8     return 0;
 9 }
10 /*
11 codeblocks:报错:条件运算符.cpp|7|error: operands to ?: have different types 'int' and 'const char*'|
12 
13 1:”1″不是同一类型
14 :前后必须是同一类型or能隐式转换的类型
15 */
条件运算符

 

posted on 2013-11-01 15:31  桑海  阅读(139)  评论(0编辑  收藏  举报