<legend id='uVMHF'><style id='uVMHF'><dir id='uVMHF'><q id='uVMHF'></q></dir></style></legend>
        <bdo id='uVMHF'></bdo><ul id='uVMHF'></ul>
    1. <tfoot id='uVMHF'></tfoot>
      <i id='uVMHF'><tr id='uVMHF'><dt id='uVMHF'><q id='uVMHF'><span id='uVMHF'><b id='uVMHF'><form id='uVMHF'><ins id='uVMHF'></ins><ul id='uVMHF'></ul><sub id='uVMHF'></sub></form><legend id='uVMHF'></legend><bdo id='uVMHF'><pre id='uVMHF'><center id='uVMHF'></center></pre></bdo></b><th id='uVMHF'></th></span></q></dt></tr></i><div id='uVMHF'><tfoot id='uVMHF'></tfoot><dl id='uVMHF'><fieldset id='uVMHF'></fieldset></dl></div>

      <small id='uVMHF'></small><noframes id='uVMHF'>

        基本枚举类继承

        时间:2023-08-26
            <tbody id='1R4IZ'></tbody>
            <legend id='1R4IZ'><style id='1R4IZ'><dir id='1R4IZ'><q id='1R4IZ'></q></dir></style></legend>
              • <bdo id='1R4IZ'></bdo><ul id='1R4IZ'></ul>
                <tfoot id='1R4IZ'></tfoot>

                  <small id='1R4IZ'></small><noframes id='1R4IZ'>

                1. <i id='1R4IZ'><tr id='1R4IZ'><dt id='1R4IZ'><q id='1R4IZ'><span id='1R4IZ'><b id='1R4IZ'><form id='1R4IZ'><ins id='1R4IZ'></ins><ul id='1R4IZ'></ul><sub id='1R4IZ'></sub></form><legend id='1R4IZ'></legend><bdo id='1R4IZ'><pre id='1R4IZ'><center id='1R4IZ'></center></pre></bdo></b><th id='1R4IZ'></th></span></q></dt></tr></i><div id='1R4IZ'><tfoot id='1R4IZ'></tfoot><dl id='1R4IZ'><fieldset id='1R4IZ'></fieldset></dl></div>

                2. 本文介绍了基本枚举类继承的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  是否有一种模式可以让我从 C++ 中的另一个枚举继承枚举??

                  Is there a pattern where I can inherit enum from another enum in C++??

                  类似的东西:

                  enum eBase 
                  {
                     one=1, two, three
                  };
                  
                  
                  enum eDerived: public eBase
                  {
                     four=4, five, six
                  };
                  

                  推荐答案

                  不可能.枚举没有继承.

                  Not possible. There is no inheritance with enums.

                  您可以改为使用具有命名 const int 的类.

                  You can instead use classes with named const ints.

                  示例:

                  class Colors
                  {
                  public:
                    static const int RED = 1;
                    static const int GREEN = 2;
                  };
                  
                  class RGB : public Colors
                  {
                    static const int BLUE = 10;
                  };
                  
                  
                  class FourColors : public Colors
                  {
                  public:
                    static const int ORANGE = 100;
                    static const int PURPLE = 101;
                  };
                  

                  这篇关于基本枚举类继承的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:C++:将枚举值打印为文本 下一篇:我应该使用#define、enum 还是const?

                  相关文章

                3. <tfoot id='HtG8Y'></tfoot>
                    <bdo id='HtG8Y'></bdo><ul id='HtG8Y'></ul>

                  <small id='HtG8Y'></small><noframes id='HtG8Y'>

                  1. <i id='HtG8Y'><tr id='HtG8Y'><dt id='HtG8Y'><q id='HtG8Y'><span id='HtG8Y'><b id='HtG8Y'><form id='HtG8Y'><ins id='HtG8Y'></ins><ul id='HtG8Y'></ul><sub id='HtG8Y'></sub></form><legend id='HtG8Y'></legend><bdo id='HtG8Y'><pre id='HtG8Y'><center id='HtG8Y'></center></pre></bdo></b><th id='HtG8Y'></th></span></q></dt></tr></i><div id='HtG8Y'><tfoot id='HtG8Y'></tfoot><dl id='HtG8Y'><fieldset id='HtG8Y'></fieldset></dl></div>

                    1. <legend id='HtG8Y'><style id='HtG8Y'><dir id='HtG8Y'><q id='HtG8Y'></q></dir></style></legend>