#include <iostream>
#include <memory>

using namespace std;

class A {
  public:
    A(){}
    int i;
    int j;
};

class B {
  public:
    B() = default;
    int i;
    int j;
};

int main()
{
  cout << "1" << endl;
  for( int i = 0; i < 3; ++i)
  {
    A* pa = new A();
    B* pb = new B();
    cout << "A : " << pa->i << "," << pa->j << endl;
    cout << "B : " << pb->i << "," << pb->j << endl;
    delete pa;
    delete pb;
  }
  cout << "2" << endl;                                                                                                                                                                                                                         
  for( int i = 0; i < 3; ++i)
  {
    shared_ptr<A> pa = make_shared<A>();
    shared_ptr<B> pb = make_shared<B>();
    cout << "A : " << pa->i << "," << pa->j << endl;
    cout << "B : " << pb->i << "," << pb->j << endl;
  }
  cout << "3" << endl;
  for( int i = 0; i < 3; ++i)
  {
    shared_ptr<A> pa ( new A() );
    shared_ptr<B> pb ( new B() );
    cout << "A : " << pa->i << "," << pa->j << endl;
    cout << "B : " << pb->i << "," << pb->j << endl;
  }
  cout << "4" << endl;
  for( int i = 0; i < 3; ++i)
  {
    shared_ptr<A> pa ( new A );
    shared_ptr<B> pb ( new B );
    cout << "A : " << pa->i << "," << pa->j << endl;
    cout << "B : " << pb->i << "," << pb->j << endl;
  }
  return 0;
}
