使用TI编译器定义类型的成员

时间:2014-08-16 16:30:39

标签: c++ texas-instruments

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

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。

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

1 个答案:

答案 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;
 };