【发布时间】:2013-02-01 15:41:38
【问题描述】:
我的c++ 代码中的一行内容如下:
cout<<(i%3==0 ? "Hello\n" : i) ;//where `i` is an integer.
但我收到此错误:
operands to ?: have different types 'const char*' and 'int
如何修改代码(最少字符)?
【问题讨论】:
-
使用标准的
if-else语句有什么问题?