English 中文(简体)
A. 获取结构中定义的 en价值
原标题:Accessing enum values defined in a struct

如果我有:

struct LineChartScene::LineChartSceneImpl
{
    enum ContextMenuAction {ShowLabels, ShowPoints, SaveAsImage};
};

如何在外查阅<代码>。 结构? 参看LineChartScene:LineChartSceneImpl:ContextMenuAction:ShowLabels 工作会奏效,但无。 I m using C++, Qt Publishing 2.2.1.

最佳回答
struct LineChartScene::LineChartSceneImpl
{
    enum ContextMenuAction {ShowLabels, ShowPoints, SaveAsImage};
};

使用

LineChartScene::LineChartSceneImpl::ShowLabels

http://en.wikipedia.org/wiki/C%2B%2B11#Strongly_typed_e amountations”rel=“noreferer” (C++11) 也有strong打了tums

enum class Enum2 : unsigned int {Val1, Val2};

列举范围也界定为列举名称的范围。 采用数字名称要求进行明确的范围。 <><>>> 附件 Enum2:Val1 的定义。

此外,C++11将使旧式的列举能够提供明确的范围以及基本类型的定义:

enum Enum3 : unsigned long {Val1 = 1, Val2};

清单名称在列举范围( 代码>)中界定。 Enum3:Val1 ,但对于落后的兼容性,也把点名列入封面范围。

问题回答

使用:

LineChartScene::LineChartSceneImpl::ShowLabels

无<代码>的通知 ContextMenuAction in the line. 这是因为在 类型内没有涵盖面值标签,而是在范围上加以界定,在这种情况下,范围是类别。 我知道这段话题是unintuitive,但这正是设计的。

你不需要大事的名称,但你正在正确轨道上:

LineChartScene::LineChartSceneImpl::ShowLabels

Just LineChartScene:LineChartSceneImpl:ShowLabels





相关问题
Finding the Highest Value in an Enumeration

I m writing a method which determines the highest value in a .NET enumeration so I can create a BitArray with one bit for each enum value: pressedKeys = new BitArray(highestValueInEnum<Keys>());...

Conversion of Enum to Enumerable

To convert Enum to Enumerable ,I use public enum Flags { Trivial=1, Minor, Major, Critical } IEnumerable<int> n = Enumerable.Range((int)Flags.Trivial, (...

Subclass check, is operator or enum check

A couple of friends was discussing the use of inheritance and how to check if a subclass is of a specific type and we decided to post it here on Stack. The debate was about if you should implement a ...

Enum scoping issues

I try to keep things as local as possible, so I put enums at class scope, even if they are shared between two classes (I put it in the class that "goes better" with it.) This has worked out great, but ...

How do I sort enum members alphabetically in Java?

I have an enum class like the following: public enum Letter { OMEGA_LETTER("Omega"), GAMMA_LETTER("Gamma"), BETA_LETTER("Beta"), ALPHA_LETTER("Alpha"), private final String ...

C++ enum value initialization

I have an enum declared in my code as: enum REMOTE_CONN { REMOTE_CONN_DEFAULT = 0, REMOTE_CONN_EX_MAN = 10000, REMOTE_CONN_SD_ANNOUNCE, REMOTE_CONN_SD_IO, REMOTE_CONN_AL, ...

WCF: Enforce equal DataContracts on both sides

I m wondering if it is possible to have WCF make sure that the DataContracts on both sides of a connection are exactly the same (and throw an exception when trying to connect if they are not). For ...

热门标签