[問題] invalid use of incomplete type
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
Linux
問題(Question):
請問不同class之間要使用另一個class的function 其中
String
a::test(int istrue)
{
StringAccum sa;
if (istrue == 1)
{ sa << "yes" << "\n";}
else
{ sa << "no " << "\n";}
return sa.take_string();
}
另一個class b要使用a的這個function
String
b::print_links()
{
// LinkTableMulti _link_table;
StringAccum sa;
sa << _a->test(1);
return sa.take_string();
}
hh檔裡面 加了 class a *_a;
但是我會編譯不過 產生
error: invalid use of incomplete type ‘struct a’
error: forward declaration of ‘struct a'
不太了解這個錯誤的原因是為什麼?
請提示一下 感謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.144.129
推
03/20 23:47, , 1F
03/20 23:47, 1F
→
03/20 23:47, , 2F
03/20 23:47, 2F
→
03/20 23:47, , 3F
03/20 23:47, 3F
我有include a 進header檔阿
找到問題了 沒有ELEMENT_REQUIRES(a)
謝謝樓上解答
※ 編輯: tanker 來自: 140.113.144.129 (03/21 17:51)
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章