• <small id='KefIa'></small><noframes id='KefIa'>

        <bdo id='KefIa'></bdo><ul id='KefIa'></ul>

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

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

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

        时间:2023-10-07

          <bdo id='gQeTp'></bdo><ul id='gQeTp'></ul>

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

          <legend id='gQeTp'><style id='gQeTp'><dir id='gQeTp'><q id='gQeTp'></q></dir></style></legend>
            <tbody id='gQeTp'></tbody>
          • <tfoot id='gQeTp'></tfoot>

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

                  本文介绍了在 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++ 中,我可以从结构派生一个类吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何对 C++ 代码的性能进行基准测试? 下一篇:无法理解 LARGE_INTEGER 结构

                  相关文章

                  最新文章

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

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

                      <bdo id='ChbJI'></bdo><ul id='ChbJI'></ul>
                    <tfoot id='ChbJI'></tfoot>