boost::smart_ptr<Base> ptr(new Derived);


見出し.

ホントは半角にしたかった.



何か投稿しようとしたらメンテとか言って記事消されたw

このエントリ書くの二回目.

#include <boost/shared_ptr.hpp>

struct Base {
  ~Base() throw(){} // NOT virtual
};

struct Derived : Base {
  ~Derived() throw(){}
};

int main(){

  boost::shared_ptr<Base> ptr(new Derived); // ok

}

okだって,すごいね.


ソースみて勉強しなきゃ.