情况:我正在尝试在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
如果您使用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] 删除。
我来说两句