Skip to content

Instantly share code, notes, and snippets.

@jcowles
Created February 7, 2017 16:48
Show Gist options
  • Save jcowles/6dd014c71cd42693209203f9485c8438 to your computer and use it in GitHub Desktop.
Save jcowles/6dd014c71cd42693209203f9485c8438 to your computer and use it in GitHub Desktop.
Pimpl with nested forward declaration
#include "Object.h"
// Define Foo.
struct Object::Foo {
int x;
// Methods can live with data, no namespace required.
void DoStuff() {
}
};
Object::Object()
{
_pimpl->DoStuff();
}
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