Created
August 1, 2017 21:34
-
-
Save lighterowl/8dcf054f28d3326ea0098d203d388bf0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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