gpt4 book ai didi

C++ C2100 初始化结构变量时的非法间接访问

转载 作者:太空宇宙 更新时间:2023-11-03 10:23:45 25 4
gpt4 key购买 nike

我正在使用“VS2017 Community”,Windows 7 平台。尝试下一步时出现错误 C2100:

struct Conf {
unsigned int id;
int test1;
int test2;
int test3;
int test4;
int test5;
int test6;
};

Conf cf({
0,
0,
0,
0,
0,
0,
0
}); //<-- Here is error - C2100 Illegal Indirection

谁能告诉我这里可能出现的问题是什么?谢谢。

最佳答案

这个结构没有构造函数。您想要的代码如下:

struct Conf {
unsigned int id;
int test1;
int test2;
int test3;
int test4;
int test5;
int test6;
};

Conf cf = {
0,
0,
0,
0,
0,
0,
0
}; // Array initializer for struct type.

关于C++ C2100 初始化结构变量时的非法间接访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49807527/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com