diff --git a/examples/c++/glr/ast.hh b/examples/c++/glr/ast.hh index 20fab2c5f..b352efc93 100644 --- a/examples/c++/glr/ast.hh +++ b/examples/c++/glr/ast.hh @@ -11,8 +11,7 @@ public: : parents_ (0) {} - virtual ~Node () - {} + virtual ~Node (); void free () { @@ -30,6 +29,9 @@ protected: int parents_; }; +Node::~Node () +{} + static std::ostream& operator<< (std::ostream& o, const Node &node) @@ -55,12 +57,7 @@ public: child2->parents_ += 1; } - ~Nterm () - { - for (int i = 0; i < 3; ++i) - if (children_[i]) - children_[i]->free (); - } + ~Nterm (); std::ostream& print (std::ostream& o) const { @@ -82,12 +79,21 @@ private: Node *children_[3]; }; +Nterm::~Nterm () +{ + for (int i = 0; i < 3; ++i) + if (children_[i]) + children_[i]->free (); +} + + class Term : public Node { public: Term (const std::string &text) : text_ (text) {} + ~Term(); std::ostream& print (std::ostream& o) const { @@ -98,3 +104,7 @@ public: private: std::string text_; }; + +Term::~Term () +{ +}