标签:pimpl idiom cheshire cat compiler firewall id
pimpl idiom// my_class.h class my_class { // ... all public and protected stuff goes here ... private: class impl; unique_ptr<impl> pimpl; // opaque type here };
// my_class.cpp class my_class::impl { // defined privately here // ... all private data and functions: all of these // can now change without recompiling callers ... }; my_class::my_class(): pimpl( new impl ) { // ... set impl values ... }
既能最小化编译依赖,又能接口与实现分离。
标签:pimpl idiom cheshire cat compiler firewall id
原文地址:http://blog.csdn.net/flyfish1986/article/details/39697991