CPlusPlusThings/codingStyleIdioms/5_pImpl/pimpl.cpp
Light-City 4f149eec72 update
2019-12-12 16:09:55 +08:00

48 lines
522 B
C++

//
// Created by light on 19-12-9.
//
#include <iostream>
using namespace std;
// pImpl: Pointer-to-Implementation
class private_foo;
class foo {
public:
foo();
~foo();
void bar();
private:
private_foo *pImpl;
};
class private_foo {
public:
void bar() {
cout<<"private_foo invoke bar funciton."<<endl;
}
private:
int m1;
string m2;
};
foo::foo() : pImpl(new private_foo()) {
}
foo::~foo() {
}
void foo::bar() {
pImpl->bar();
}
int main() {
foo f;
f.bar();
}