fup
This commit is contained in:
+18
-8
@@ -11,37 +11,47 @@ void printTree(const NodePtr& startNode, int indent = 0) {
|
||||
}
|
||||
}
|
||||
|
||||
int main2() {
|
||||
std::cout << "Creatin...\n\n";
|
||||
auto root = std::make_shared<SimpleNode>("Root");
|
||||
std::cout << "Nice!\n\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::cout << "Entering main scope...\n\n";
|
||||
|
||||
{
|
||||
auto root = std::make_shared<SimpleNode>("Root");
|
||||
auto child2 = std::make_shared<SimpleNode>("Child2");
|
||||
auto child2 = std::make_shared<SimpleNode>("Child1");
|
||||
|
||||
root->linkChild(child2);
|
||||
std::cout << "\nInit tree:\n\n\n";
|
||||
printTree(root);
|
||||
|
||||
|
||||
{
|
||||
auto child1 = std::make_shared<SimpleNode>("Child1");
|
||||
auto child1 = std::make_shared<SimpleNode>("Child2");
|
||||
root->linkChild(child1);
|
||||
auto subchild = std::make_shared<SimpleNode>("SubChild");
|
||||
auto subchild = std::make_shared<SimpleNode>("SubChild2");
|
||||
child1->linkChild(subchild);
|
||||
auto child3 = std::make_shared<SimpleNode>("Child3");
|
||||
root->linkChild(child3);
|
||||
auto subchild2 = std::make_shared<SimpleNode>("SubChild2");
|
||||
auto subchild2 = std::make_shared<SimpleNode>("SubChild3");
|
||||
child3->linkChild(subchild2);
|
||||
|
||||
std::cout << "Initial tree:\n";
|
||||
std::cout << "\nAnother tree:\n\n\n";
|
||||
printTree(root);
|
||||
|
||||
std::cout << "\nUnlinking Child1...\n";
|
||||
child1->unlinkParent();
|
||||
std::cout << "\nTree after unlink:\n";
|
||||
std::cout << "\nTree after unlink:\n\n\n";
|
||||
printTree(root);
|
||||
}
|
||||
|
||||
std::cout << "\nTree after scope out:\n";
|
||||
std::cout << "\nTree after scope out:\n\n\n";
|
||||
printTree(root);
|
||||
|
||||
std::cout << "\n\n";
|
||||
}
|
||||
|
||||
std::cout << "\nExited main scope. All smart pointers destroyed.\n";
|
||||
|
||||
Reference in New Issue
Block a user