diff --git a/31.PImplPattern/01.Picture/PImpl.jpg b/31.PImplPattern/01.Picture/PImpl.jpg new file mode 100644 index 0000000..70827f4 Binary files /dev/null and b/31.PImplPattern/01.Picture/PImpl.jpg differ diff --git a/31.PImplPattern/02.Code/demo.cpp b/31.PImplPattern/02.Code/demo.cpp new file mode 100644 index 0000000..59b098b --- /dev/null +++ b/31.PImplPattern/02.Code/demo.cpp @@ -0,0 +1,27 @@ +#include "demo.h" +// include other necessary files +#include .... + +class PAimpl +{ +public: + void func1(int a, char* b) + { + // implementation + } + bool isEnabled() + { + // implementation + return true; + } +}; + +void A::func1(int a, char* b) +{ + pimpl->func1(a, b); +} + +bool A::isEnabled() +{ + return pimpl->isEnabled(); +} \ No newline at end of file diff --git a/31.PImplPattern/02.Code/demo.h b/31.PImplPattern/02.Code/demo.h new file mode 100644 index 0000000..a33cf26 --- /dev/null +++ b/31.PImplPattern/02.Code/demo.h @@ -0,0 +1,22 @@ +/* header file */ + +// forward declaration +class PAimpl; + +class A +{ +public: + A() + { + // initial work + } + ~A() { + // free resource + } +public: + void func1(int a, char* b); + bool isEnabled(); + // other public interface which will exposed outside +private: + PAimpl* pimpl; +}; \ No newline at end of file