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

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

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

        <tfoot id='RFMZQ'></tfoot>

        什么是 C++ 中的复制构造函数?

        What is a copy constructor in C++?(什么是 C++ 中的复制构造函数?)
        <tfoot id='C1tJG'></tfoot>

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

          <tbody id='C1tJG'></tbody>

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

                1. 本文介绍了什么是 C++ 中的复制构造函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在 Scott Meyers 的 Effective C++ 的第 6 页中,定义了术语复制构造函数".我一直在使用 Schiltdt 的书作为我的参考,但我找不到任何提到复制构造函数的内容.我明白了,但这是 C++ 的标准部分吗?当按值传递类时,这样的构造函数会被调用吗?

                  On page 6 of Scott Meyers's Effective C++, the term 'copy constructor' is defined. I've been using Schiltdt's book as my reference and I can find no mention of copy constructors. I get the idea but is this a standard part of c++? Will such constructors get called when a pass a class by value?

                  推荐答案

                  复制构造函数具有以下形式:

                  A copy constructor has the following form:

                  class example 
                  {
                      example(const example&) 
                      {
                          // this is the copy constructor
                      }
                  }
                  

                  以下示例显示了它的调用位置.

                  The following example shows where it is called.

                  void foo(example x);
                  
                  int main(void)
                  {
                      example x1; //normal ctor
                      example x2 = x1; // copy ctor
                      example x3(x2); // copy ctor
                  
                      foo(x1); // calls the copy ctor to copy the argument for foo
                  
                  }
                  

                  这篇关于什么是 C++ 中的复制构造函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Unable to access non-const member functions of objects in C++ std::set(无法访问 C++ std::set 中对象的非常量成员函数)
                  Constructing std::function argument from lambda(从 lambda 构造 std::function 参数)
                  STL BigInt class implementation(STL BigInt 类实现)
                  Sync is unreliable using std::atomic and std::condition_variable(使用 std::atomic 和 std::condition_variable 同步不可靠)
                  Move list element to the end in STL(在 STL 中将列表元素移动到末尾)
                  Why is overloading operatoramp;() prohibited for classes stored in STL containers?(为什么禁止对存储在 STL 容器中的类重载 operatoramp;()?)
                  <tfoot id='HS0KO'></tfoot>
                2. <i id='HS0KO'><tr id='HS0KO'><dt id='HS0KO'><q id='HS0KO'><span id='HS0KO'><b id='HS0KO'><form id='HS0KO'><ins id='HS0KO'></ins><ul id='HS0KO'></ul><sub id='HS0KO'></sub></form><legend id='HS0KO'></legend><bdo id='HS0KO'><pre id='HS0KO'><center id='HS0KO'></center></pre></bdo></b><th id='HS0KO'></th></span></q></dt></tr></i><div id='HS0KO'><tfoot id='HS0KO'></tfoot><dl id='HS0KO'><fieldset id='HS0KO'></fieldset></dl></div>
                    <tbody id='HS0KO'></tbody>
                3. <legend id='HS0KO'><style id='HS0KO'><dir id='HS0KO'><q id='HS0KO'></q></dir></style></legend>

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

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