void Feature::Visit(IVisitable& visitable) { if (m_pLanguage != nullptr) visitable.Accept(*m_pLanguage); visitable.Accept(Tags()); visitable.Accept(*this); if (m_pBackground != nullptr) { m_pBackground->Visit(visitable); } for (ScenarioDefinition* scenario : m_ScenarioDefinitions) { scenario->Visit(visitable); } }
/* * main */ int main() { GoVisitor v; IVisitable * h = new Human; IVisitable * f = new Fish; IVisitable * b = new Bird; h->accept( v ); // Human::walk f->accept( v ); // Fish::swim b->accept( v ); // Bird::fly delete b; delete f; delete h; }
bool IsMatch(const IVisitable& o) { matched_ = nullptr; o.Accept(*this); return matched_ != nullptr; }
PrivateVisitor(IVisitable& v) { v.Accept(*this); }
void Example::Visit(IVisitable& visitable) { visitable.Accept(*this); }