简体   繁体   English

嵌套结构会影响性能吗?

[英]Do nested structs affect performance?

If the nested struct will contain only static constant members, will it affect performance anyhow? 如果嵌套结构仅包含静态常量成员,那么它是否会影响性能? I want to use it to scope these constants. 我想用它来限制这些常量。

class File {

    public:

        struct Mode {
            static const int Read = 0x01, Write = 0x02, Append = 0x04;
        };

};

Is this a good practice? 这是一个好习惯吗?

完全不是,变量是在编译时而不是运行时解析的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM