相关疑难解决方法(0)

c ++ 03 libstdc ++与c ++ 11中的虚假副本

考虑以下代码:

#include <iostream>
#include <string>
#include <map>

using namespace std;

class Foo
{
public:
   Foo() : _x(0) 
   {
       cout << "Default" << endl;
   }
   Foo(int a) : _x(a)
   {
      cout << "Param" << endl;
   }

   Foo(Foo const &foo) :
      _x(foo._x)
   {
      cout << "Copy" << endl;
   }

   Foo& operator=(Foo const &foo)
   {
      cout << "Assignment" << endl;
      _x = foo._x;
      return *this;
   }

   int get(void)
   {
      return _x;
   }

private:
   int _x;
};

int main(int argc, char *argv [])
{ …
Run Code Online (Sandbox Code Playgroud)

c++ libstdc++ c++11

6
推荐指数
1
解决办法
193
查看次数

标签 统计

c++ ×1

c++11 ×1

libstdc++ ×1