#include <iostream>
#include <memory>
using namespace std;

class AFriend;

class A {
  friend class AFriend;
private:
  void f() { cout << "A" << endl; }
};

class AFriend {
public:
  AFriend(A* a);
private:
  class impl;
  std::unique_ptr<impl> pimpl;
};

class AFriend::impl {
public:
  impl(A* a) { a->f(); }
};

AFriend::AFriend(A* a) : pimpl(new impl(a))
{
}

int main() {
  A a;
  AFriend a_friand(&a);
}
