1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
| int main(const int argc, const char* argv[])
{
auto dirRed = std::make_shared<Composite>("Red");
auto dirGreen = std::make_shared<Composite>("Green");
auto dirBlue = std::make_shared<Composite>("Blue");
auto dirBlack = std::make_shared<Composite>("Black");
auto dirWhite = std::make_shared<Composite>("White");
dirBlack->addNode(std::make_shared<Leaf>("A"));
dirBlack->addNode(std::make_shared<Leaf>("B"));
dirBlack->addNode(std::make_shared<Leaf>("C"));
dirRed->addNode(dirGreen);
dirGreen->addNode(dirBlue);
dirBlue->addNode(dirBlack);
dirBlue->addNode(dirWhite);
dirWhite->addNode(std::make_shared<Leaf>("D"));
dirWhite->addNode(std::make_shared<Leaf>("E"));
dirRed->print();
return 0;
}
|