<<< Print contents of the list | Index | The STL list class >>> |
Since Node implementation is using pointers, a copy constructor is absolutely crucial to programmer's peace of mind!
class Node {
friend void print_list( Node const& head );
Node* pnext;
public:
int data;
// Constructor taking initial value:
Node( int value = 0 )
: pnext( NULL ), data( value )
{
}
// Copy constructor:
Node( Node const& other )
: pnext( NULL ), data( other.data )
{
}
};
<<< Print contents of the list | Index | The STL list class >>> |