[問題] function pointer有預設參數
如題
我要如何透過一個function pointer來呼叫一個有預設參數的function呢?
例如 下面這段程式沒辦法成功編譯
謝謝
void foo(int i=3) {
cout << i << endl;
}
void (*bar)(int);
int main() {
bar = &foo;
foo(); // ok, prints '3'
bar(1); // ok, prints '1'
bar(); // doesn't compile...
// default argument lost via function pointer
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.26.98.191
推
06/25 12:55, , 1F
06/25 12:55, 1F
→
06/25 12:56, , 2F
06/25 12:56, 2F
→
06/25 12:56, , 3F
06/25 12:56, 3F
推
06/25 14:56, , 4F
06/25 14:56, 4F
→
06/25 15:24, , 5F
06/25 15:24, 5F
→
06/26 01:23, , 6F
06/26 01:23, 6F
→
06/26 01:25, , 7F
06/26 01:25, 7F
→
06/26 01:25, , 8F
06/26 01:25, 8F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章