[ create a new paste ] login | about

Link: http://codepad.org/sktELTDk    [ raw code | output | fork ]

zajo - C++, pasted on Feb 9:
#include "boost/shared_ptr.hpp"
#include <iostream>

struct b
{
};

struct d1: b
{
  ~d1()
  {
  std::cout << "~d1() called!\n";
  }
};

struct d2: b
{
  ~d2()
  {
  std::cout << "~d2() called!\n";
  }
};

template <class T>
boost::shared_ptr<b> create()
{
  return boost::shared_ptr<T>(new T);
}

int main()
{
  boost::shared_ptr<b> b1=create<d1>();
  boost::shared_ptr<b> b2=create<d2>();
}


Output:
1
2
~d2() called!
~d1() called!


Create a new paste based on this one


Comments: