缺少类型说明符-int假定C4430错误
missing type specifier - int assumed C4430 error
情况:我正试图在Nodes类中创建一系列方法,所有这些方法都将使用由playerName(string)和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>
,以确保它本身是"完整的")。
string
位于std
命名空间中,因此将其称为std::string
。您也不需要C++中的typedef
语法:
#include <string>
struct listnode
{
std::string playerName;
listnode * next;
};
制作:
typedef struct listnode
{ ^^^^^^^^
std::string playerName;
^^^^^
struct listnode * next;
^^^^^^
} listnode;
相关文章:
- 是否假定reinterpret_cast<char*>(myTypePtr)指向数组?
- 如何在C++中克服此 C4430 编译器错误?
- 由于"error C4430: missing type specifier - int assumed. Note: C++ does not support default-int",我现在无法编
- 缺少类型说明符 - 假定为 int.注意 c++ 不支持 default-int
- 错误:C4430:缺少类型说明符-假定为int.注意:C++不支持default-int
- C ++回测问题:如何检查构造函数在假定失败时是否失败(给定输入的无效参数)
- 声明 Windows API 结构 (DCB) 的对象 - 错误 C4430:缺少类型说明符 - 假定为 int
- C++假定错误 C4430 int
- CREATESTRUCT错误C4430:缺少类型说明符-假定为int.注意:C++不支持默认的int C:xdc
- 错误 1 错误 C4430:缺少类型说明符 - 假定为 int.注意:C++不支持默认整数
- 字符串无法识别?C4430:缺少类型说明符 - 假定为 int
- 模板类:错误 C4430:缺少类型说明符 - 假定为 int.注意:C++不支持默认整数
- 错误 C4430、C2146 - 缺少类型说明符 - 假定为 int.注意:C++不支持默认整数
- srand(time(NULL)):错误 C4430:缺少类型说明符 - 假定为 int.注意:C++不支持默认整数
- 错误C4430:缺少类型说明符-假定为int
- 缺少类型说明符-int假定C4430错误
- 错误c4430缺少类型说明符-假定为int.注意:c++不支持default-int生成器
- C4430错误-缺少类型说明符-假定为int
- 使用流模板以避免复制代码会产生"错误 C4430:缺少类型说明符 - 假定为 int"
- 编译器错误C4430:缺少类型说明符-假定为int