0

我有一个看起来像这样的类:

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。

顺便说一句,实际的类是一个模板,但我很确定这不是问题。

4

1 回答 1

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;
 };
于 2014-08-16T16:48:11.523 回答