1. <tfoot id='WhMkT'></tfoot>
    2. <small id='WhMkT'></small><noframes id='WhMkT'>

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

        在 C++ 中,我可以从结构派生一个类吗

        in C++, can I derive a class from a struct(在 C++ 中,我可以从结构派生一个类吗)

          <i id='Qtp24'><tr id='Qtp24'><dt id='Qtp24'><q id='Qtp24'><span id='Qtp24'><b id='Qtp24'><form id='Qtp24'><ins id='Qtp24'></ins><ul id='Qtp24'></ul><sub id='Qtp24'></sub></form><legend id='Qtp24'></legend><bdo id='Qtp24'><pre id='Qtp24'><center id='Qtp24'></center></pre></bdo></b><th id='Qtp24'></th></span></q></dt></tr></i><div id='Qtp24'><tfoot id='Qtp24'></tfoot><dl id='Qtp24'><fieldset id='Qtp24'></fieldset></dl></div>
          • <bdo id='Qtp24'></bdo><ul id='Qtp24'></ul>
              <tbody id='Qtp24'></tbody>
          • <small id='Qtp24'></small><noframes id='Qtp24'>

                <tfoot id='Qtp24'></tfoot><legend id='Qtp24'><style id='Qtp24'><dir id='Qtp24'><q id='Qtp24'></q></dir></style></legend>

                  本文介绍了在 C++ 中,我可以从结构派生一个类吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  问题说明了一切.我是否允许从结构派生一个类,还是应该创建一个嵌入我的结构并定义复制构造函数和 = 运算符以在两者之间移动的类?

                  The question says it all really. Am I allowed derive a class from a struct, or should I create a class that embeds my struct and defines copy constructors and an = operator to move between the two?

                  推荐答案

                  在 C++ 中 struct(几乎)与 class 同义(除了不同的默认访问级别),所以是的,你可以.

                  In C++ struct is (almost) synonymous to a class (except of different default access level), so yes, you can.

                  struct A {
                  // fields are public by default
                  };
                  
                  class B: public A {
                  // fields are private by default
                  };
                  

                  我不熟悉 MFC,但它看起来像是在尝试同时维护 C 和 C++ API.

                  I'm not familiar with MFC, but it looks like an attempt to maintain both C and C++ APIs.

                  这篇关于在 C++ 中,我可以从结构派生一个类吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Consistent pseudo-random numbers across platforms(跨平台一致的伪随机数)
                  Vary range of uniform_int_distribution(改变uniform_int_distribution的范围)
                  What is a seed in terms of generating a random number?(就生成随机数而言,种子是什么?)
                  Is 1.0 a valid output from std::generate_canonical?(1.0 是 std::generate_canonical 的有效输出吗?)
                  Getting big random numbers in C/C++(在 C/C++ 中获取大随机数)
                  What is the best way to generate random numbers in C++?(在 C++ 中生成随机数的最佳方法是什么?)
                      <tbody id='2pdH2'></tbody>
                    1. <tfoot id='2pdH2'></tfoot>
                      <legend id='2pdH2'><style id='2pdH2'><dir id='2pdH2'><q id='2pdH2'></q></dir></style></legend>
                        • <bdo id='2pdH2'></bdo><ul id='2pdH2'></ul>

                            <small id='2pdH2'></small><noframes id='2pdH2'>

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