feature: add PImpl Pattern demo code.
parent
7235d125ef
commit
1d0bae0753
Binary file not shown.
After Width: | Height: | Size: 72 KiB |
|
@ -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();
|
||||
}
|
|
@ -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;
|
||||
};
|
Loading…
Reference in New Issue