作者wawi2 (@@)
看板C_and_CPP
标题[问题] ternary ? operator
时间Wed Dec 12 00:22:18 2018
因为工作升迁需求 需要考证照
在准备的时候遇到两个很怪的问题 而且compile也不过
想请问怎麽解释下面的code?
(工作上要是有人这样写我会想砍人 但这是考试...you know...)
1.
int main() {
int a = 3;
cout<<s(a)<<endl;
return 0;
}
int s(int n)
{
if(n == 0) return 1;
return s(n?1)*n;
}
这边要怎麽解释 s(n?1)
2. complex class本身有real part (re)跟imaginary part (im)
但这边的 this?>re + t.re是啥意思 没看过?>这东西
complex complex::operator+ (complex &t){
complex temp;
temp.re = this?>re + t.re;
temp.im = this?>im + t.im;
return temp;
}
谢谢
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 108.5.129.170
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/C_and_CPP/M.1544545340.A.B01.html
※ 编辑: wawi2 (108.5.129.170), 12/12/2018 00:30:21
1F:→ wawi2: 对了 因为这毕竟是人家背出来的考题 或许有笔误。。。。 12/12 00:39
2F:→ stucode: 我觉得这应该不是程式码,是填空题吧? 12/12 00:59
3F:→ stucode: 问号处都用-(减号)填入看起来很合理。 12/12 00:59
4F:推 mmmmei: 我投笔误一票 12/12 01:00
5F:推 ckc1ark: 我猜是用到non-ascii的 dash-like symbol encoding出问题 12/12 01:11
6F:→ wawi2: 谢谢大家 把?全换成-就都合理了 12/12 01:30
7F:→ wawi2: 看来明显是原作者把word转存成pdf时 把全形-转成? 12/12 01:37
8F:推 b0920075: 笑了 12/12 05:06
9F:→ MOONRAKER: 噗 你要不要修改标题加上 (被骗了) 12/12 17:42