gpt4 book ai didi

c++ - C++ 结构中的前向声明编译器错误

转载 作者:太空宇宙 更新时间:2023-11-04 16:26:13 25 4
gpt4 key购买 nike

这在 Visual C++ 2010 中编译。

它不编译和 MINGW。

struct nextifcondinfo
{
hash_map <string, nextifcondinfo> next;
int action;
};

I get an error message:
Description Resource Path Location Type
forward declaration of 'struct nextifcondinfo' C/C++ Problem

能不能告诉我mingw用什么switch来解决?或者您还有其他想法吗?

最佳答案

我不认为您的代码应该可以编译,但它确实取决于 hash_map 的实现。看来您幸运地使用了 VC++ 而不幸地使用了 MinGW。

例如要解决使用指针

struct nextifcondinfo
{
hash_map <string, nextifcondinfo*> next;
int action;
};

您也可以使用智能指针。

关于c++ - C++ 结构中的前向声明编译器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11808004/

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