相关疑难解决方法(0)

为什么在构建结构时在Visual C++ 2008中会收到这些警告?

我有这个代码

typedef struct
{
    const char* fooString;
    const bool  fooBool;
}fooStruct;
Run Code Online (Sandbox Code Playgroud)

而这个初始化程序:

static const fooStruct foo[] =
{
    {"file1", true},
    {"file2", false},
    ....
};
Run Code Online (Sandbox Code Playgroud)

使用此代码,我在VS2008中有3个警告:

error C2220: warning treated as error - no 'object' file generated  
warning C4510: '<unnamed-tag>' : default constructor could not be generated
warning C4512: '<unnamed-tag>' : assignment operator could not be generated
warning C4610: struct '<unnamed-tag>' can never be instantiated - user defined constructor required 
Run Code Online (Sandbox Code Playgroud)

c++ visual-c++-2008 visual-c++

6
推荐指数
2
解决办法
3172
查看次数

标签 统计

c++ ×1

visual-c++ ×1

visual-c++-2008 ×1