我有一个看起来像这样的课程:
class In {
public:
struct Member{
In name;
};
In() {}
private:
static const int aCapacity = 16;
static const int oCapacity = 16;
};
当我尝试编译它时,我收到一个错误:error #71: incomplete type is not allowed
此代码使用Microsoft编译器进行编译。想知道是否有人知道如何为TI工作?
AFAIK,TI使用GCC 4.8.3。
顺便说一句,实际的课程是模板,但我很确定这不是问题。答案 0 :(得分:1)
这不应该编译:编译器无法推断Member
的布局,因为它还没有解析整个类In
。
只需声明嵌套的struct
,然后在 In
的定义后定义:
class In {
public:
struct Member;
In() {}
private:
static const int aCapacity = 16;
static const int oCapacity = 16;
};
struct In::Member{
In name;
};