Reputation: 1584
I have the following header file:
namespace First
{
namespace Second
{
class Limit
{
public:
enum Status
{
GOOD,
BAD
};
}
}
}
Since it's proprietary I have changed the names, and only left the relevant info.
In my own class I have...
First::Second::Limit::Status limit_status = First::Second::Limit::Status::OK;
But I get an error: error: class First::Second::Limit::Status is not a class or namespace
I am able to declare a variable of that enum, but not set it to any of the values. How do I fix this?
Upvotes: 2
Views: 500
Reputation: 61910
If you have C++11, use enum class
:
namespace First
{
namespace Second
{
class Limit
{
public:
enum class Status
{
GOOD,
BAD
};
}
}
}
Now you can use Status
as a scope. If not, you'll have to not include the Status::
part.
Upvotes: 4
Reputation: 19767
First::Second::Limit::Status limit_status = First::Second::Limit::GOOD;
You don't need the Status
bit. Think of it as defining several const int
s inside Limit
, you wouldn't say Limit::int::GOOD
.
Upvotes: 4