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

    <tfoot id='cE8EU'></tfoot>

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

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

      头文件中带有默认参数的构造函数

      Constructors with default parameters in Header files(头文件中带有默认参数的构造函数)
    1. <tfoot id='IbVYw'></tfoot>
      • <i id='IbVYw'><tr id='IbVYw'><dt id='IbVYw'><q id='IbVYw'><span id='IbVYw'><b id='IbVYw'><form id='IbVYw'><ins id='IbVYw'></ins><ul id='IbVYw'></ul><sub id='IbVYw'></sub></form><legend id='IbVYw'></legend><bdo id='IbVYw'><pre id='IbVYw'><center id='IbVYw'></center></pre></bdo></b><th id='IbVYw'></th></span></q></dt></tr></i><div id='IbVYw'><tfoot id='IbVYw'></tfoot><dl id='IbVYw'><fieldset id='IbVYw'></fieldset></dl></div>

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

          <bdo id='IbVYw'></bdo><ul id='IbVYw'></ul>
            <tbody id='IbVYw'></tbody>
          <legend id='IbVYw'><style id='IbVYw'><dir id='IbVYw'><q id='IbVYw'></q></dir></style></legend>

                本文介绍了头文件中带有默认参数的构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个像这样的 cpp 文件:

                I have a cpp file like this:

                #include Foo.h;
                Foo::Foo(int a, int b=0)
                {
                    this->x = a;
                    this->y = b;
                }
                

                我如何在 Foo.h 中引用它?

                How do I refer to this in Foo.h?

                推荐答案

                .h:

                class Foo {
                    int x, y;
                    Foo(int a, int b=0);
                };
                

                .cc:

                #include "foo.h"
                
                Foo::Foo(int a,int b)
                    : x(a), y(b) { }
                

                你只为声明添加默认值,而不是实现.

                You only add defaults to declaration, not implementation.

                这篇关于头文件中带有默认参数的构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                Constructor initialization Vs assignment(构造函数初始化 Vs 赋值)
                Is a `=default` move constructor equivalent to a member-wise move constructor?(`=default` 移动构造函数是否等同于成员移动构造函数?)
                Has the new C++11 member initialization feature at declaration made initialization lists obsolete?(声明时新的 C++11 成员初始化功能是否使初始化列表过时了?)
                Order of constructor call in virtual inheritance(虚继承中构造函数调用的顺序)
                How to use sfinae for selecting constructors?(如何使用 sfinae 选择构造函数?)
                Initializing a union with a non-trivial constructor(使用非平凡的构造函数初始化联合)
                <legend id='8rKcb'><style id='8rKcb'><dir id='8rKcb'><q id='8rKcb'></q></dir></style></legend>
                  <tbody id='8rKcb'></tbody>

                    1. <tfoot id='8rKcb'></tfoot>

                      <small id='8rKcb'></small><noframes id='8rKcb'>

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