fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. namespace library {
  5.  
  6. // library.h
  7. //---------------------------
  8. class Interface {
  9. public:
  10. Interface();
  11.  
  12. ~Interface();
  13.  
  14. void f();
  15.  
  16. private:
  17. class Impl;
  18. Impl* m_impl;
  19. };
  20. //---------------------------
  21.  
  22. // library.cpp
  23. //---------------------------
  24. class Interface::Impl {
  25. public:
  26. void f() {
  27. std::cout << "f" << std::endl;
  28. }
  29. };
  30.  
  31. Interface::Interface() {
  32. m_impl = new Interface::Impl();
  33. }
  34.  
  35. Interface::~Interface() {
  36. delete m_impl;
  37. }
  38.  
  39. void Interface::f() {
  40. m_impl->f();
  41. }
  42. //---------------------------
  43.  
  44. }
  45.  
  46. int main()
  47. {
  48. auto o = library::Interface();
  49. o.f();
  50. }
Success #stdin #stdout 0s 3272KB
stdin
Standard input is empty
stdout
f