以下の内容はhttps://so-wh.at/entry/20090527/p2より取得しました。


placement new

使う機会はなさそうな。

#include <iostream>
#include <new>

using namespace std;

class Foo {
  int i_;

public:
  Foo() : i_(0) {
    cout << "Foo(0)" << endl;
  }

  Foo(int i) : i_(i) {
    cout << "Foo(" << i_ << ")" << endl;
  }

  Foo(const Foo& foo) {
    cout << "copy constructor << " << foo.i_  << endl;
    this->i_ = foo.i_;
  }

  ~Foo() {
    cout << "~Foo(" << i_ << ")" << endl;
  }
};

int main() {
  Foo foo;
  new (&foo) Foo(100);
  return 0;
}


Foo(0)
Foo(100)
~Foo(100)
続行するには何かキーを押してください . . .




以上の内容はhttps://so-wh.at/entry/20090527/p2より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14