I have 2 .h files which contain 2 classes, List and a ListNode. I want to change both classes into 1 class, List. Is this possible?

Code:#ifndef LIST_H #define LIST_H #include <iostream> using std::cout; using std::cin; using std::endl; #include "ListNode.h" template< typename T > class List { public: List() : m_pFirst( 0 ), m_pLast( 0 ) { } ~List(); void insertAtFront( const T& data ); void insertAtBack( const T& data ); bool removeFromFront( T& data ); bool removeFromBack( T& data ); bool isEmpty() const { return m_pFirst == 0; } void print() const; private: ListNode< T >* m_pFirst; ListNode< T >* m_pLast; ListNode< T >* getNewNode( const T& data ) { ListNode< T >* pNewNode = new ListNode< T >( data ); return pNewNode; } }; //DECLARE INLINE FUNCTIONS HERE template< typename T > List< T >::~List() { if ( !isEmpty() ) { cout << "Destroying nodes ...\n"; ListNode< T > *currentPtr = m_pFirst; ListNode< T > *tempPtr; while ( currentPtr != 0 ) { tempPtr = currentPtr; cout << tempPtr->m_Data << '\n'; currentPtr = currentPtr->m_pNext; delete tempPtr; } } cout << "All nodes destroyed\n\n"; getch(); } template< typename T > void List< T >::insertAtFront( const T& data ) { ListNode< T > *pNewNode = getNewNode( data ); if ( isEmpty() ) m_pFirst = m_pLast = pNewNode; else { pNewNode->m_pNext = m_pFirst; m_pFirst = pNewNode; } } template< typename T > void List< T >::insertAtBack( const T& data ) { ListNode< T > *pNewNode = getNewNode( data ); if( isEmpty() ) m_pFirst = m_pLast = pNewNode; else { m_pLast->m_pNext = pNewNode; m_pLast = pNewNode; } } template< typename T > bool List< T >::removeFromFront( T& data ) { if ( isEmpty() ) return false; else { ListNode< T > *tempPtr = m_pFirst; if ( m_pFirst == m_pLast ) m_pFirst = m_pLast = 0; else m_pFirst = m_pFirst->m_pNext; data = tempPtr->m_Data; delete tempPtr; return true; } } template< typename T > bool List< T >::removeFromBack( T& data ) { if ( isEmpty() ) return false; else { ListNode< T > *tempPtr = m_pLast; if ( m_pFirst == m_pLast ) m_pFirst = m_pLast = 0; else { ListNode< T > *currentPtr = m_pFirst; while ( currentPtr->m_pNext != m_pLast ) currentPtr = currentPtr->m_pNext; m_pLast = currentPtr; currentPtr->m_pNext = 0; } data = tempPtr->m_Data; delete tempPtr; return true; } } template< typename T > void List< T >::print() const { if( isEmpty() ) { cout << "The list is empty\n\n"; return; } ListNode< T > *currentPtr = m_pFirst; cout << "The list is: "; while ( currentPtr != 0 ) { cout << currentPtr->m_Data << ' '; currentPtr = currentPtr->m_pNext; } cout << "\n\n"; } #endif //LIST_H

ListNode

Code:#include <iostream> #include <conio.h> using std::cout; using std::cin; using std::endl; #ifndef LISTNODE_H #define LISTNODE_H template< typename T> class List; template< typename T > class ListNode { friend class List< T >; public: ListNode( const T& data ) : m_Data( data ), m_pNext( 0 ) { } T getData() const { return m_Data; } private: T m_Data; ListNode< T >* m_pNext; }; #endif // LISTNODE_H