作者ric2k1 (Ric)
看板EE_DSnP
標題Re: [問題] class的member function若有default ar …
時間Sat Dec 8 23:40:39 2007
※ 引述《popo4231 (小泰)》之銘言:
: 到底放哪邊比較好呢
: 實際測試是不論放哪一邊都不會error
: 只要不兩邊都放就好了
: 想知道老師比較常放哪邊以及其原因
Default argument, be it for class member functions or regular global functions,
can only be specified in the "FIRST TIME" it appears in the program.
Therefore, it's better to specify it in the function prototype.
For class member functions,
it's better to be in class definition, i.e. .h file.
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.121.134.54
1F:推 Knossos:為什麼放在.cpp會過?那已經不是第一次出現了,不是嗎? 12/09 16:33
2F:→ ric2k1:的確放在 cpp 會過, 他的規定是說 "不能 redefine"... 12/09 18:16
3F:→ ric2k1:不過我覺得在 .h 中沒有定義然後在.cpp中才定義是蠻奇怪的 12/09 18:17