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

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

      <legend id='oDz20'><style id='oDz20'><dir id='oDz20'><q id='oDz20'></q></dir></style></legend>

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

        • <bdo id='oDz20'></bdo><ul id='oDz20'></ul>

        C++ 多个同名类

        C++ Multiple classes with same name(C++ 多个同名类)

        • <small id='2OKBI'></small><noframes id='2OKBI'>

          <tfoot id='2OKBI'></tfoot>

              • <legend id='2OKBI'><style id='2OKBI'><dir id='2OKBI'><q id='2OKBI'></q></dir></style></legend>
                  <bdo id='2OKBI'></bdo><ul id='2OKBI'></ul>
                  <i id='2OKBI'><tr id='2OKBI'><dt id='2OKBI'><q id='2OKBI'><span id='2OKBI'><b id='2OKBI'><form id='2OKBI'><ins id='2OKBI'></ins><ul id='2OKBI'></ul><sub id='2OKBI'></sub></form><legend id='2OKBI'></legend><bdo id='2OKBI'><pre id='2OKBI'><center id='2OKBI'></center></pre></bdo></b><th id='2OKBI'></th></span></q></dt></tr></i><div id='2OKBI'><tfoot id='2OKBI'></tfoot><dl id='2OKBI'><fieldset id='2OKBI'></fieldset></dl></div>
                    <tbody id='2OKBI'></tbody>
                • 本文介绍了C++ 多个同名类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  假设我有两个不同的 cpp 文件.两者都声明了具有相同名称的类,但可能是完全不同的结构(或者可能是相同的结构,不同的实现).这些类不会出现在头文件中.(举个例子,假设它们是不同列表类的节点类.)

                  Say I have two different cpp files. Both declare classes with the same name, but perhaps a totally different structure (or perhaps the same structure, different implementation). The classes do not appear in the header files. (As an example, suppose they are Node classes for different list classes.)

                  我见过这些类冲突.这是标准所期望的吗?这个问题有什么解决方案?

                  I've seen these classes conflict. Is this expected by the standard? What solutions are there to this problem?

                  更新:

                  正如答案/评论所建议的那样,匿名命名空间正是我想要的.

                  As suggested by answers/comments, anonymous namespaces are what I was looking for.

                  推荐答案

                  解决这个问题的标准方法是将类包装在不同的 命名空间.

                  The standard way around this problem is to wrap the classes in different namespaces.

                  这篇关于C++ 多个同名类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Is Type(::x); valid?(是类型(::x);有效的?)
                  Difference between an inline function and static inline function(内联函数和静态内联函数的区别)
                  Compilation fails randomly: quot;cannot open program databasequot;(编译随机失败:“无法打开程序数据库)
                  Too many initializers error for a simple array in bcc32(bcc32 中的简单数组的初始值设定项过多错误)
                  No Member named stoi in namespace std(命名空间 std 中没有名为 stoi 的成员)
                  Error using a constexpr as a template parameter within the same class(在同一个类中使用 constexpr 作为模板参数时出错)
                • <small id='5n0Kz'></small><noframes id='5n0Kz'>

                    <bdo id='5n0Kz'></bdo><ul id='5n0Kz'></ul>

                      • <legend id='5n0Kz'><style id='5n0Kz'><dir id='5n0Kz'><q id='5n0Kz'></q></dir></style></legend>
                          <tbody id='5n0Kz'></tbody>

                        <tfoot id='5n0Kz'></tfoot>

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