Skip to content

Instantly share code, notes, and snippets.

@xavery
Created August 1, 2017 21:34
Show Gist options
  • Save xavery/8dcf054f28d3326ea0098d203d388bf0 to your computer and use it in GitHub Desktop.
Save xavery/8dcf054f28d3326ea0098d203d388bf0 to your computer and use it in GitHub Desktop.
struct FooInterface; // full definition irrelevant here
struct FooFactoryInterface {
virtual FooInterface* create(int p1, float p2) = 0;
};
class Foo : public FooInterface {
public:
Foo(FooFactoryInterface& f):f_(f) {}
bool init(int p1, float p2) {
foo_.reset(f_.create(p1, p2));
return foo_;
}
private:
FooFactoryInterface& f_;
std::unique_ptr<FooInterface> foo_;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment