Skip to content

Instantly share code, notes, and snippets.

@ktnyt
Last active May 17, 2017 05:56
Show Gist options
  • Save ktnyt/95c274aef336936a1810326073821d30 to your computer and use it in GitHub Desktop.
Save ktnyt/95c274aef336936a1810326073821d30 to your computer and use it in GitHub Desktop.
#include <memory>
struct Human { std::shared_ptr<Human> lover; };
struct Mika : public Human {};
struct Miria : public Human {};
int main() {
auto mika = std::make_shared<Mika>();
auto miria = std::make_shared<Miria>();
/* 永遠の愛 */
mika->lover = miria;
miria->lover = mika;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment