小编Max*_*Max的帖子

预计在左侧的结构.或.*但它是一种结构

我得到的编译错误structure required on left side of . or .*chest.contents[0],而且chest是一个结构:

class Item {
public:
    int id;
    int dmg;
};

class Chest {
public:
    Item contents[10];
};

int main() 
{
    Chest chest();

    Item item = chest.contents[0];

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++ compiler-errors most-vexing-parse

3
推荐指数
2
解决办法
2291
查看次数

标签 统计

c++ ×1

compiler-errors ×1

most-vexing-parse ×1