+//void destroy_tree_rep (tree_rep* rep);
inline tree::tree (const tree& x): rep (x.rep) { rep->ref_count++; }
-inline tree::~tree () {
- if ((--rep->ref_count)==0) destroy_tree_rep (rep); }
+
+inline tree::~tree ()
+{
+ if ((--rep->ref_count)==0) {
+ //destroy_tree_rep (rep);
+ delete rep;
+ rep = NULL;
+ }
+}
I am a bit confused by this. Is this necessary?
We should recursively delete the tree,
so it does not suffice to just delete the pointer...
I see now; that is the purpose of the virtual destructor...
But now I am again confused, because the old routine
destroy_tree_rep should precisely do the same thing
as the virtual destructor. Apparently, a string is sometimes
not a string or a compound not a compound...
By the way, what is the effect of "rep = NULL" ?
This is the only real change I can see,
but I do not see why this should stabilize the code.