Hey everyone! So I need to write two header files and they attach to the main cpp file, but we can not change the cpp file. They have to attach and make the program run. Please help!

Main cpp CANNOT be changed!

//22 34 56 4 19 2 89 90 0 14 32 88 125 56 11 43 55 -999 

#include <iostream>
#include "unorderedLinkedList.h"

using namespace std;

int main()
{
    unorderedLinkedList<int> list, subList;

    int num;                                         

    cout << "Enter numbers ending with -999" << endl;                                        
    cin >> num;                                  

    while (num != -999)                              
    {
        list.insertLast(num);                        
        cin >> num;                                  
    }

    cout << endl;                                  

    cout << "List: ";                  
    list.print();                                    
    cout << endl;                                      
    cout << "Length of the list: " << list.length() << endl;                                   


    list.divideMid(subList);

    cout << "Lists after splitting list" << endl;

    cout << "list: ";
    list.print();                                    
    cout << endl;                                      
    cout << "Length of the list: " << list.length() << endl;      

    cout << "sublist: ";
    subList.print();                                     
    cout << endl;                                      
    cout << "Length of subList: " << subList.length() << endl;
    system("pause");
    return 0;                   
}

linkedList header

#ifndef H_linkedList
#define H_linkedList

using namespace std; 

template<class Type>
class linkedList
{
public:
    linkedList(); //Constructor
    linkedList(nodeType<Type> *ptr); //parameter
    Type operator*(); // overload the operator
    linkedList<Type> operator++(); 
    bool operator==(const linkedList<Type>& right) const;
    bool operator!=(const linkedList<Type>& right) const;

protected:
    int count;
    nodeType<Type> *first;
    nodeType<Type> *last;

private:
    nodeType<Type> *current;
};

template<class Type>
linkedList<Type>::linkedList()
{
    current = NULL;
}

template <class Type>
linkedList<Type>::linkedList(nodeType<Type> *ptr)
{
    current = ptr;
}

template<class Type>
Type linkedList<Type>::operator*()
{
    return current->info;
}

template <class Type>
linkedList<Type> linkedList<Type>::operator++()
{
    current = current->link;
    return *this;
}

template <class Type>
bool linkedList<Type>::operator==(const linkedList<Type>& right) const
{
    return (current == right.current);
}

template<class Type>
bool linkedList<Type>::operator!=(const linkedList<Type>& right) const
{
    return (current != right.current);
}
#endif

unorderedLinkedList h file

#ifndef H_unorderedLinkedList
#define H_unorderedLinkedList

#include "linkedList.h"

using namespace std;

template <class Type>
class unorderedLinkedList : public linkedList < Type >
{
public:
    bool search(const Type& searchItem) const; 
    void insertFirst(const Type& newItem);
    void insertLast(const Type& newItem);
    void deleteNode(const Type& deleteItem);
};
#endif

OK, and what problem are you having? Can you explain in detail what is going on, and where you need further help?

This article has been dead for over six months. Start a new discussion instead.