Created
May 25, 2017 13:59
-
-
Save njlr/c9ab184c80c93cb7e3c440dafc1ac630 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 Tree { | |
string const name; | |
value_ptr<Tree> left; | |
value_ptr<Tree> right; | |
Tree( | |
string const& name, | |
value_ptr<Tree> const& left = value_ptr<Tree>{}, | |
value_ptr<Tree> const& right = value_ptr<Tree>{}) | |
: name{name} | |
, left{left} | |
, right{right} | |
{} | |
}; | |
int main() { | |
Tree root = Tree{ | |
"root", | |
Tree{"l0"} | |
Tree{"r0"} | |
}; | |
root.left = root; // Copy of root assigned to left | |
root.right = root; // and we don't have cyclic references | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment