[英]C++: “error C4430: missing type specifier - int assumed” For constructor and invalid declaration for destructor
I have this CResources class declaration, and i get this error 我有这个CResources类声明,我得到这个错误
"error C4430: missing type specifier - int assumed" “错误C4430:缺少类型说明符 - 假设为int”
#include <set>
#include <unordered_set>
const int R_NUMBER = 5;
typedef enum {
M,
} OBJECT_ENUM;
typedef enum {
FILE_O,
} RESOURCE_ENUM;
typedef struct _resourcesMapping {
CBuffer apiBuffer;
int ObjectIndex;
};
class CResources {
int rCount;
int* resources;
public:
CResources(int);
~CResources();
int getCount();
int getObjectsCount();
int rOrder[R_NUMBER];
std::set<int> ObjectsSet;
};
What am I doing wrong? 我究竟做错了什么?
Add the code before the deceleration. 在减速之前添加代码。
You forgot to #include <set>
. 你忘了#include <set>
。
AFTER EDIT 编辑后
On line 18: CBuffer apiBuffer;
第18行: CBuffer apiBuffer;
, the identifier CBuffer
is unknown. ,标识符CBuffer
未知。 Also, the typedef
on typedef struct _resourcesMapping
is ignored since you didn't declare anything. 此外, typedef
的typedef struct _resourcesMapping
因为你没有任何声明被忽略。
Also, identifiers that begin with underscores are reserved in the global namespace and shouldn't be used _resourcesMapping
. 此外,以下划线开头的标识符在全局命名空间中保留,不应使用_resourcesMapping
。
typedef struct _resourcesMapping {
CBuffer apiBuffer;
int ObjectIndex;
}; //missing typedef name
it should be something like: 它应该是这样的:
typedef struct _resourcesMapping {
CBuffer apiBuffer;
int ObjectIndex;
}ResourcesMapping;
Other than that, I don't think there are any errors. 除此之外,我认为没有任何错误。 Your error seems to be elsewhere. 你的错误似乎在其他地方。
I think you need just: 我认为你只需要:
using namespace std;
It helped me anyway. 无论如何它帮助了我。
Generally use of "using namespace xxx;" 一般使用“using namespace xxx;” is a bad idea. 是个坏主意。 It might cause problems later on. 它可能会在以后引起问题。 An example where it will be causing problems is shown below. 下面将显示导致问题的示例。
void functionX();
namespace mynamespace {
void functionX();
};
I recommend that prefixing is used instead such as 我建议使用前缀,例如
mynamespace::functionX();
functionX();
Hth 心连心
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.