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

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

  • <tfoot id='WLS4i'></tfoot>

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

      1. <legend id='WLS4i'><style id='WLS4i'><dir id='WLS4i'><q id='WLS4i'></q></dir></style></legend>
      2. C++ 继承 - 无法访问的基础?

        时间:2023-08-02
      3. <legend id='O2Q9a'><style id='O2Q9a'><dir id='O2Q9a'><q id='O2Q9a'></q></dir></style></legend>

            <tbody id='O2Q9a'></tbody>

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

        1. <tfoot id='O2Q9a'></tfoot>

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

                • 本文介绍了C++ 继承 - 无法访问的基础?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我似乎无法使用基类作为函数参数,我是否弄乱了我的继承?

                  I seem to be unable to use a base class as a function parameter, have I messed up my inheritance?

                  我的主要内容如下:

                  int some_ftn(Foo *f) { /* some code */ };
                  Bar b;
                  some_ftn(&b);
                  

                  还有以这种方式从 Foo 继承的 Bar 类:

                  And the class Bar inheriting from Foo in such a way:

                  class Bar : Foo
                  {
                  public:
                      Bar();
                      //snip
                  
                  private:
                      //snip
                  };
                  

                  这样不行吗?我似乎无法在主函数中进行该调用

                  Should this not work? I don't seem to be able to make that call in my main function

                  推荐答案

                  你必须这样做:

                  class Bar : public Foo
                  {
                      // ...
                  }
                  

                  C++中class的默认继承类型是private,所以任何publicprotected成员都来自基类仅限于 private.struct 另一方面,默认继承是 public.

                  The default inheritance type of a class in C++ is private, so any public and protected members from the base class are limited to private. struct inheritance on the other hand is public by default.

                  这篇关于C++ 继承 - 无法访问的基础?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:为什么C++不允许继承友谊? 下一篇:更改派生类中的函数访问模式

                  相关文章

                  最新文章

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

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

                    <tfoot id='eoayq'></tfoot>

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