class component
{
public:
virtual void print()const = 0;
};
class composite :public component
{
component* m_child;
public:
void setChild(component* child)
{
m_child = child;
}
virtual void print()const{ cout << "composite" << endl; }
};
class leaf :public component
{
public:
void print()const { cout <<" leaf Node "<< endl; }
};
void _tmain()
{
leaf node;
composite comp;
comp.setChild(&node);
component* p = ∁
p->print();
}