Listing 2. StrNode Copy Constructor

StrNode::StrNode ( const StrNode & srcnode )
/*
Function:   StrNode copy constructor
Pre:  srcnode is a valid node instance
Post: *this is a discrete copy of srcnode
   srcnode is unchanged
*/
{
strptr_ = new ( char [ strlen
      ( srcnode.strptr_ ) + 1 ] );
assert ( strptr_ );
strcpy ( strptr_, srcnode.strptr_ );
if ( srcnode.next_ )
   {
   next_ = new StrNode ( *srcnode.next_ );
            // indirect recursion
   assert ( next_ ); // out of memory?
   }
else
   {
   next_ = 0;
   }
}