缺少类型说明符-int假定C4430错误

用户名

情况:我正在尝试在Nodes类中创建一系列方法,所有这些方法都将使用由playerName(字符串)和next(listnode)组成的结构“ listnode”。我已经在头文件中创建了该结构,因为我还将在主类中使用该结构。

错误:当我编译时,出现一个异常错误,错误为“ c4430:缺少类型说明符-假定为int。注意:C ++不支持默认int”,类似8的错误。

#ifndef STRUCTS_H
#define STRUCTS_H
#include <Windows.h>
#include <string>

typedef struct 
{
    string playerName;
    listnode * next;
} listnode;

#endif
马特·彼得森(Mats Petersson)

如果您使用C ++进行编译,则应该能够执行以下操作:

struct listnode
{
   string playername;
   listnode* next;
};

(这里不需要typedef)

如果要能够在C中进行编译,则需要为结构使用标记名:

typedef struct listnode_tag
{
   string playername;
   struct listnode_tag* next;
} listnode;

(显然string可能需要std::string使用C ++,并且#include <string>在此文件中应该有一个,只是为了确保它自己是“完整的”)。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

编译器错误C4430:缺少类型说明符-假定为int

声明Windows API结构(DCB)的对象-错误C4430:缺少类型说明符-假定为int

错误2错误C4430:缺少类型说明符-假定为int。注意:C ++不支持default-int

模板类:错误C4430:缺少类型说明符-假定为int。注意:C ++不支持default-int

对流使用模板以避免代码复制会产生“错误C4430:缺少类型说明符-假定为int”

C ++宏给出C4430错误:缺少类型说明符

错误C4430:缺少类型说明符-假定为int。注意:C ++不支持default-int-上一个解决方案不起作用

错误:缺少类型说明符

缺少类型说明符-假定为int(类问题)

Flex 的 C 错误:缺少类型说明符?

令人困惑的缺少类型说明符错误

初始化导致“缺少类型说明符-假定为int”的静态成员。

使用不同类型int和缺少类型说明符的NSArray重新定义

C ++错误:预期类型说明符

C ++ MSVC dll编译错误,缺少类型说明符和重新定义

通过在主函数中添加“返回0”无法解决“缺少类型说明符-假定为int”

Q_DECLARE_METATYPE引发缺少类型说明符错误

是unsigned int的“简单类型说明符”

从int映射到类型说明符

C ++ / ENUM /类型名称/说明符

期望 C 中的类型说明符

在 C++ 中得到预期的类型说明符错误

错误:“数字”之前的预期类型说明符

错误:'Elem' 之前的预期类型说明符

C ++应该为类对象指定类型说明符

C ++自动类型说明符的编译时间

警告:“auto”类型说明符是 C++11 扩展

C ++:const引用,类型说明符之前和之后

预期的类型说明符C ++模板类