<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'>

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

      时间:2023-09-26
    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.

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

                上一篇:继承构造函数在 C++ 中有多大用处? 下一篇:我应该总是继续使用 `sink` 构造函数或 setter 参数吗?

                相关文章

                <legend id='8rKcb'><style id='8rKcb'><dir id='8rKcb'><q id='8rKcb'></q></dir></style></legend>

                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>