fork download
  1. #include <iostream>
  2. #include <memory>
  3. using namespace std;
  4.  
  5. class AFriend;
  6.  
  7. class A {
  8. friend class AFriend;
  9. private:
  10. void f() { cout << "A" << endl; }
  11. };
  12.  
  13. class AFriend {
  14. public:
  15. AFriend(A* a);
  16. private:
  17. class impl;
  18. std::unique_ptr<impl> pimpl;
  19. };
  20.  
  21. class AFriend::impl {
  22. public:
  23. impl(A* a) { a->f(); }
  24. };
  25.  
  26. AFriend::AFriend(A* a) : pimpl(new impl(a))
  27. {
  28. }
  29.  
  30. int main() {
  31. A a;
  32. AFriend a_friand(&a);
  33. }
  34.  
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
A