Questions tagged [pimpl-idiom]

The PIMPL idiom, also known as the compilation firewall or Cheshire Cat technique, is a "private implementation" technique useful in C++ and other similar statically compiled languages.

The idiom makes use of an opaque pointer to another object (usually of a nested class type) which provides the implementation. Member functions on the outer object forward to the implementation object, which is defined in a separate source file so that the implementation is not visible in the header defining the outer class. This is a special case of the Bridge pattern.

The term Cheshire Cat (because the body disappears leaving only a smile) is older, but the more common name PIMPL idiom was popularized by Herb Sutter in GOTW #24 (and revisited in GOTW #100 and #101).

Links:

Separating Interface and Implementation in C++ compares the PIMPL idiom to other related techniques.

318 questions
-1
votes
2 answers

Error deleting std::vector in a DLL using the PIMPL idiom

I have the following code: In DLL1: in .h file: class MyClass { public: MyClass(); private: std::string m_name; }; class __declspec(dllexport) Foo { private: struct Impl; Impl *pimpl; public: Foo(); virtual…
Igor
  • 5,620
  • 11
  • 51
  • 103
-1
votes
1 answer

Qt: Objective-C header gets compiled as c++-header

I'm currently trying to implement the PIMPL-Idiom to encapsulate Objective-C functionality in a C++ class in Qt. My pro file looks as it follows: QT += core gui TARGET = testProject TEMPLATE = app SOURCES += main.cpp Helper.cpp HEADERS +=…
ParkerHalo
  • 4,341
  • 9
  • 29
  • 51
-2
votes
3 answers

Invoking constructor through PIMPL idiom design

/*Process.h*/ class Process { public: Process(ProcessID thirdParty_pid); protected: void createImpl(); private: ProcessImpl * _impl; }; /*ProcessImpl.h*/ class ProcessImpl { public : ProcessImpl(ProcessID…
user2380779
  • 11
  • 1
  • 5
1 2 3
21
22