2

Hello im a newbie from C++. For a my project i need to use a enum value similar C# example.

My Struct

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::Attributes

enum Attributes
{
    _BINARY = 0x26,
    _UNSIGNED = 0x27
};

My Example function

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;

I get error on row->attrib = Attributes::_UNSIGNED;

no have idea for this error. who are the correct solution?

Joe Martiniello
  • 323
  • 1
  • 3
  • 13

1 Answers1

1
enum Attributes
{
    _BINARY = 0x26,
    _UNSIGNED = 0x27
};
...
row->attrib = Attributes::_UNSIGNED;

My psychic debugging powers ;) tell me that the problem is that the _UNSIGNED symbol is not under the scope of Attributes, so you should be able to do:

row->attrib = _UNSIGNED;

For scoped enums you may want to use C++11's enum class.

P.S. Note also that _Upper (underscore followed by uppercase letter) names are reserved for implementations, and should not be used in your code.

Mr.C64
  • 41,637
  • 14
  • 86
  • 162