c – 访问结构中定义的枚举值

c – 访问结构中定义的枚举值,第1张

概述如果我有以下内容: struct LineChartScene::LineChartSceneImpl{ enum ContextMenuAction {ShowLabels, ShowPoints, SaveAsImage};}; 如何访问LineChartScene :: LineChartSceneImpl结构外的ShowLabels,ShowPoints等?我以为LineCha 如果我有以下内容:
struct lineChartScene::lineChartSceneImpl{    enum ContextMenuAction {ShowLabels,ShowPoints,SaveAsImage};};

如何访问lineChartScene :: lineChartSceneImpl结构外的ShowLabels,ShowPoints等?我以为lineChartScene :: lineChartSceneImpl :: ContextMenuAction :: ShowLabels可以工作,但事实并非如此.我正在使用C,Qt Creator 2.2.1.

解决方法
struct lineChartScene::lineChartSceneImpl{    enum ContextMenuAction {ShowLabels,SaveAsImage};};

用它作为

lineChartScene::lineChartSceneImpl::ShowLabels

对于您的信息,C++11 also has strong typed enums具有您期望的命名空间语义:

06002

The scoping of the enumeration is also defined as the enumeration name’s scope. Using the enumerator names requires explicitly scoping. Val1 is undefined,but Enum2::Val1 is defined.

Additionally,C++11 will allow old-style enumerations to provIDe explicit scoping as well as the deFinition of the underlying type:

06003

The enumerator names are defined in the enumeration’s scope (Enum3::Val1),but for backwards compatibility,enumerator names are also placed in the enclosing scope.

总结

以上是内存溢出为你收集整理的c – 访问结构中定义枚举值全部内容,希望文章能够帮你解决c – 访问结构中定义的枚举值所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1238021.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-06
下一篇 2022-06-06

发表评论

登录后才能评论

评论列表(0条)

保存