复制构造函数;赋值运算符

时间:2014-12-04 15:55:51

标签: c++ variable-assignment copy-constructor

我有这个小代码:

#include <iostream>

class Test {
  private:
    int i_;

 public:
    Test() :
      i_() {}

    Test(int i) :
      i_(i) {}

    ~Test() {}

    void dump() const {
      std::cout << "i " << i_ << std::endl;
    }
};

int main() {
  Test t(3);
  Test t1(t);
  Test t2(5);

  t2 = t;

  t.dump();
  t1.dump();
  t2.dump();

  return 0;
}

我知道C ++本身会构造一个复制构造函数和一个做作运算符。这就是为什么我可以编译这段代码,即使使用标志并运行它也没有任何问题。

我的问题是:

  • 为什么使用nm -C <generated file>我无法看到成员函数

-

$> g++ -W -Wall -Werror test.cpp
$> nm -C a.out
[...]
                 U _Unwind_Resume@@GCC_3.0
0000000000400a55 t __static_initialization_and_destruction_0(int, int)
0000000000400aa8 W Test::Test(int, int)
0000000000400aa8 W Test::Test(int, int)
0000000000400acc W Test::~Test()
0000000000400acc W Test::~Test()
0000000000400ad6 W Test::dump() const
[...]
$>

0 个答案:

没有答案
相关问题