C++;定义的结构中的枚举错误 你好,我是C++的新手。 对于my项目,我需要使用类似于C#示例的枚举值
我的结构C++;定义的结构中的枚举错误 你好,我是C++的新手。 对于my项目,我需要使用类似于C#示例的枚举值,c++,struct,enums,C++,Struct,Enums,我的结构 struct Rows { string name; bool primaryKey; int lenght; string defined; MyLDC::Attributes attrib; bool Nullable; bool AutoIncrement; string comment; }; Rows rw; Rows* row = &rw; MyLDC::属性 enum Attributes {
struct Rows
{
string name;
bool primaryKey;
int lenght;
string defined;
MyLDC::Attributes attrib;
bool Nullable;
bool AutoIncrement;
string comment;
};
Rows rw;
Rows* row = &rw;
MyLDC::属性
enum Attributes
{
_BINARY = 0x26,
_UNSIGNED = 0x27
};
我的示例函数
void MyLDC::CreateTable(string tablename,string primaryKey)
{
//Simple Row Implementation
row->name = "Example Row";
row->AutoIncrement = true;
row->primaryKey = true;
row->comment = "Example Row";
row->attrib = Attributes::_UNSIGNED;
我在行->属性上出错::\u未签名
我不知道这个错误。
谁是正确的解决方案
我的心灵调试能力;)告诉我问题在于\u UNSIGNED
符号不在属性的范围内,因此您应该能够执行以下操作:
row->attrib = _UNSIGNED;
对于作用域枚举,您可能需要使用C++11的enum类
p.S.另外请注意,\u Upper
(下划线后跟大写字母)名称是为实现保留的,不应在代码中使用。您会遇到什么错误?请在问题正文中包含完整的错误(完整且未编辑)。与错误无关,以下划线开头并后跟大写字母的符号名称保留用于实现(编译器和标准库)。请参见例如..Error:Attributes'不是类或命名空间|@JoeMartiniello:很高兴能提供一些帮助。我以前也去过那里:)对不起,我没去。我的情况似乎是这样的:我在做什么不同?
row->attrib = _UNSIGNED;