#include "cppframe/tree.hpp" using namespace cppframe; int main() { FrameTree tree; auto root = tree.addRoot("Root"); auto child1 = tree.addChild(root, "Child 1"); tree.addChild(child1, "Grandchild 1"); tree.addChild(child1, "Grandchild 2"); auto child2 = tree.addChild(root, "Child 2"); tree.addChild(child2, "Grandchild 3"); tree.print(); // prints the tree structure }
FrameTree tree; auto root = tree.addRoot("Root"); auto child1 = tree.addChild(root, "Child 1"); tree.addChild(child1, "Grandchild 1"); tree.addChild(child1, "Grandchild 2"); auto child2 = tree.addChild(root, "Child 2"); tree.addChild(child2, "Grandchild 3"); auto subtree = tree.copySubtree(child1); subtree->setLabel("Subtree"); tree.print(); // prints the original tree subtree->print(); // prints the copied subtreeIn this example, we create a tree structure as before and then create a new subtree by copying the node with label "Child 1" and all its children. We then change the label of the subtree to "Subtree" and print both the original tree and the copied subtree to the console. Cpp Frame Tree is part of the cppframe package library.