[問題] ternary ? operator
因為工作升遷需求 需要考證照
在準備的時候遇到兩個很怪的問題 而且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://www.ptt.cc/bbs/C_and_CPP/M.1544545340.A.B01.html
※ 編輯: wawi2 (108.5.129.170), 12/12/2018 00:30:21
→
12/12 00:39,
7年前
, 1F
12/12 00:39, 1F
→
12/12 00:59,
7年前
, 2F
12/12 00:59, 2F
→
12/12 00:59,
7年前
, 3F
12/12 00:59, 3F
推
12/12 01:00,
7年前
, 4F
12/12 01:00, 4F
推
12/12 01:11,
7年前
, 5F
12/12 01:11, 5F
→
12/12 01:30,
7年前
, 6F
12/12 01:30, 6F
→
12/12 01:37,
7年前
, 7F
12/12 01:37, 7F
推
12/12 05:06,
7年前
, 8F
12/12 05:06, 8F
→
12/12 17:42,
7年前
, 9F
12/12 17:42, 9F