[問題] ternary ? operator

看板C_and_CPP作者 (@@)時間7年前 (2018/12/12 00:22), 7年前編輯推噓3(306)
留言9則, 6人參與, 7年前最新討論串1/1
因為工作升遷需求 需要考證照 在準備的時候遇到兩個很怪的問題 而且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
我猜是用到non-ascii的 dash-like symbol encoding出問題
12/12 01:11, 5F

12/12 01:30, 7年前 , 6F
謝謝大家 把?全換成-就都合理了
12/12 01:30, 6F

12/12 01:37, 7年前 , 7F
看來明顯是原作者把word轉存成pdf時 把全形-轉成?
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
文章代碼(AID): #1S3-Gyi1 (C_and_CPP)