Skip to content

Instantly share code, notes, and snippets.

@simonlynen
Created December 16, 2014 20:11
Show Gist options
  • Save simonlynen/9ebbf0c616549f6dfe39 to your computer and use it in GitHub Desktop.
Save simonlynen/9ebbf0c616549f6dfe39 to your computer and use it in GitHub Desktop.
class C {
public:
class Key {
friend std::shared_ptr<C> make_c();
Key() {}
};
C(const Key &);
//...
};
std::shared_ptr<C> make_c() {
return std::make_shared<C>(C::Key());
}
@simonlynen
Copy link
Author

Only allow access to methods for a single other method / class without exposing the entire private section by friending.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment