本文整理汇总了C++中Composite::GetChild方法的典型用法代码示例。如果您正苦于以下问题:C++ Composite::GetChild方法的具体用法?C++ Composite::GetChild怎么用?C++ Composite::GetChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composite
的用法示例。
在下文中一共展示了Composite::GetChild方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CompositeTest
///Composite 组合模式通过和 Decorator 模式有着类似的结构图,但是 Composite 模式旨在构造 类,而 Decorator 模式重在不生成子类即可给对象添加职责。Decorator 模式重在修饰,而 Composite 模式重在表示
void CompositeTest() {
Leaf* l = new Leaf();
l->Operation();
Composite* com = new Composite();
com->Add(l);
com->Operation();
NS_Composite::Component* ll = com->GetChild(0);
ll->Operation();
}
示例2: main
int main()
{
Leaf *pLeaf1 = new Leaf();
Leaf *pLeaf2 = new Leaf();
Composite *pComposite = new Composite;
pComposite->Add(pLeaf1);
pComposite->Add(pLeaf2);
pComposite->Operation();
cout << "pComposite->GetChild(2)->Operation():" << endl;
pComposite->GetChild(2)->Operation();
delete pComposite;
cin.get();
return 0;
}
示例3: main
int main()
{
Leaf * pLeaf1 = new Leaf();
Leaf * pLeaf2 = new Leaf();
Composite * pComposite = new Composite;
pComposite->Add(pLeaf1);
pComposite->Add(pLeaf2);
pComposite->Operation();
pComposite->GetChild(2)->Operation();
delete pComposite;
return 0;
}
示例4: main
int main()
{
Composite* pComposite = new Composite("Compostie");
pComposite->Add(new Leaf("leaf1"));
pComposite->Add(new Leaf("leaf2"));
pComposite->Operation();
pComposite->GetChild(1)->Operation();
delete pComposite;
Composite* myComposite = new Composite("myCompostie");
myComposite->Add(new Leaf("leaf3"));
myComposite->Operation();
delete myComposite;
return 0;
}