【发布时间】:2015-02-09 11:50:47
【问题描述】:
我有以下场景:
header.h:
class A
{
public:
class B; // incomplete type
private:
// is never used outside of source file for A
std::vector<B> vector_of_bs; // template
}
source1.cpp:
class A::B {}; // defined here
到这里为止一切都很好。现在,如果我想在其他地方使用class A,它就行不通了:
source2.cpp: 使用 A 类且不编译
vector(721): error C2036: 'A::B *' : 未知大小
在编译类模板成员函数'std::vector<_ty> &std::vector<_ty>::operator =(const std::vector<_ty> &)'时
在 VS2010 中。如何链接 source1.o 中 std::vector 的模板特化?
我还需要将它与declspec(_dllimport)...一起使用...
【问题讨论】:
标签: c++ templates forward-declaration