精華區beta C_and_CPP 關於我們 聯絡資訊
fun本身就是地址 ※ 引述《costbook (CB)》之銘言: : 函式有位址嗎?如果有一個函式void fun(), : 然後這樣寫: : cout<<&fun; : 編譯器會說: : [Warning] the address of `void fun()', will always : evaluate as `true' : 這是為什麼? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 166.111.62.41
costbook:那為什麼 "will always evaluate as `true'"?? 06/12 18:51
cole945:http://www.newty.de/fpt/fpt.html 06/12 18:58
cole945:因為函式位址一定大於0, 非0即為true (在c/c++是這樣) 06/12 18:59
cole945:取址最好還要是加 &, 不是所有的編譯器都支援不加& @o@" 06/12 19:00