class Element { public: virtual ~Element(); virtual void Accept(Visitors) = 0; protected: Element(); }; class ElementA : public Element { public: ElementA(); virtual void Accept(Visitors v) { v.VisitElementA(this); } }; class ElementB : public Element { public: ElementB(); virtual void Accept(Visitors v) { v.VisitElementB(this); } };