简体   繁体   English

C ++:“错误C4430:缺少类型说明符 - 假设为int”对于构造函数和析构函数的无效声明

[英]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. 此外, typedeftypedef 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.

相关问题 缺少类型说明符-int假定C4430错误 - missing type specifier - int assumed C4430 error 错误 C4430:缺少类型说明符 - 假定为 int - error C4430: missing type specifier - int assumed shared-ptr 和错误 C4430:缺少类型说明符 - 假定为 int - C++ - shared-ptr and error C4430: missing type specifier - int assumed - C++ C ++ - 运算符重载错误C4430:缺少类型说明符 - 假定为int - C++ - Operator Overload Error C4430: missing type specifier - int assumed C ++-错误C4430:缺少类型说明符(用于构造函数???) - C++ - Error C4430: missing type specifier (for a constructor???) 字符串无法识别? C4430:缺少类型说明符-假定为int - string not recognized? C4430: missing type specifier - int assumed 在模板函数中“C4430:缺少类型说明符 - 假定为int” - “C4430: missing type specifier - int assumed” in a template function 错误C4430:缺少类型说明符-假定为int。 C ++不支持default-int - error C4430: missing type specifier - int assumed. C++ does not support default-int 错误 C4430:缺少类型说明符 - 假定为 int。 注意:C++ 不支持 default-int" - error C4430: missing type specifier - int assumed. Note: C++ does not support default-int" 错误1错误C4430:缺少类型说明符-假定为int。 注意:C ++不支持default-int - Error 1 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM