一個類的成員函數調用另一個類的公有成員函數應該沒問題,見如下代碼:
結果遍得過,鏈不過。VC如下錯誤:
1>正在链接...
1>CmdTree.obj : error LNK2019: 无法解析的外部符号 "public: void __thiscall CCmdTreeNode::SetPfProc(void (__cdecl*const)(void *))" (?SetPfProc@CCmdTreeNode@@QAEXQ6AXPAX@Z@Z),该符号在函数 "public: unsigned char __thiscall CCmdTree::Insert(class ATL::CStringT<wchar_t,class StrTraitMFC_DLL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const * const,void const * const)" (?Insert@CCmdTree@@QAEEQBV?$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@QBX@Z) 中被引用
1>CmdTree.obj : error LNK2019: 无法解析的外部符号 "public: void __thiscall CCmdTreeNode::SetStrCmd(class ATL::CStringT<wchar_t,class StrTraitMFC_DLL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > >)" (?SetStrCmd@CCmdTreeNode@@QAEXV?$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@@Z),该符号在函数 "public: unsigned char __thiscall CCmdTree::Insert(class ATL::CStringT<wchar_t,class StrTraitMFC_DLL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const * const,void const * const)" (?Insert@CCmdTree@@QAEEQBV?$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@QBX@Z) 中被引用
1>
後來研究,把內聯函數改成不內聯函數就可以了。編譯器優化掉了?尚不明白。。。