開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
GCC
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
Complie Error
餵入的資料(Input):
預期的正確結果(Expected Output):
錯誤結果(Wrong Output):
strcut A incomplete type
程式碼(Code):(請善用置底文網頁, 記得排版)
#include <iostream>
using namespace std;
struct A;
void fun(A a){
a();
}
struct A{
void operator()(){cout << "A() called" << endl;}
};
int main(){
fun(A());
return 0;
}
補充說明(Supplement):
這是一題測驗題目
如果將fun寫到struct A後面即可compile正確
請問有什麼方式在不更改code順序
也不更改main以及struct A的前提下
只能更改fun本身以及之前的code
可以避免incomplete type?
謝謝!
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.162.85.51
※ 文章網址: http://www.ptt.cc/bbs/C_and_CPP/M.1399043710.A.0F2.html
→
05/02 23:42, , 1F
05/02 23:42, 1F
→
05/03 00:02, , 2F
05/03 00:02, 2F
→
05/03 00:02, , 3F
05/03 00:02, 3F
推
05/03 02:09, , 4F
05/03 02:09, 4F
推
05/03 07:11, , 5F
05/03 07:11, 5F
→
05/03 07:13, , 6F
05/03 07:13, 6F
→
05/03 12:30, , 7F
05/03 12:30, 7F
→
05/03 15:19, , 8F
05/03 15:19, 8F
推
05/03 17:01, , 9F
05/03 17:01, 9F
→
05/03 17:02, , 10F
05/03 17:02, 10F
→
05/03 18:18, , 11F
05/03 18:18, 11F
→
05/04 10:20, , 12F
05/04 10:20, 12F
→
05/04 10:21, , 13F
05/04 10:21, 13F
推
05/04 12:19, , 14F
05/04 12:19, 14F
→
05/04 12:19, , 15F
05/04 12:19, 15F
→
05/04 22:39, , 16F
05/04 22:39, 16F
→
05/09 03:50, , 17F
05/09 03:50, 17F