Created
February 7, 2017 16:48
-
-
Save jcowles/6dd014c71cd42693209203f9485c8438 to your computer and use it in GitHub Desktop.
Pimpl with nested forward declaration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Object.h" | |
// Define Foo. | |
struct Object::Foo { | |
int x; | |
// Methods can live with data, no namespace required. | |
void DoStuff() { | |
} | |
}; | |
Object::Object() | |
{ | |
_pimpl->DoStuff(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Object | |
{ | |
public: | |
Object(); | |
private: | |
// Explicit nested forward declaration required. | |
struct Foo; | |
// Standard pimpl ptr. | |
Foo* _pimpl; | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment