Question: I have the main.cpp and I already have the header file which you can modify but the only thing I dont have is clist.cpp main.cpp

I have the main.cpp and I already have the header file which you can modify but the only thing I dont have is clist.cpp

I have the main.cpp and I already have the header file which

main.cpp

#include "CList.cpp"

/* Purpose: Test the linked list class using a menu driven */

/* program */

/* Input: users choice to perform an operation */

/* Output: menu of choices and results of users operations. */

/***************************************************************/

// printMenu displays a menu of choices and returns the user's choice

int printMenu();

// InsertList inserts an item into the list parameter

void insertListItem ( CList & );

// deleteList deletes an item from the list parameter

void deleteListItem ( CList & );

// searchItem searches for an item in the list parameter

void searchListItem ( CList );

//************************** main program ************************/

int main()

{

CList l;

int choice;

cout

choice = printMenu();

while ( choice != 6 )

{

switch ( choice )

{

case 1 : insertListItem( l );

break;

case 2 : deleteListItem ( l );

break;

case 3 : l.printList();

break;

case 4 : searchListItem ( l );

break;

case 5 : cout

break;

default :cout

break;

}

choice = printMenu();

}

CList l2;

l2 = l;

cout

l2.printList();

cout

return 0;

}

//********************functions implementation ********************//

int printMenu ()

{

int c;

cout

cout

cout

cout

cout

cout

cin>>c;

return c;

}

void insertListItem ( CList &l )

{

int num;

cout

cin>>num;

l.insertItem(num);

cout

}

void deleteListItem ( CList &l )

{

int num;

cout

cin>>num;

if ( l.searchItem (num))

{

l.deleteItem (num);

cout

}

else cout

}

void searchListItem ( CList l )

{

int num;

cout

cin>>num;

if ( l.searchItem (num))

cout

else cout

}

this is header file that u can change from linked list to clist

#include

using namespace std;

/* Purpose: generic sorted linked list class - header file */

/***************************************************************/

#ifndef LLIST_H

#define LLIST_H

template

struct node

{

T info;

node *next;

};

template

class LList

{

private:

node *first;

public:

//Constructor

LList();

// Destructor

~LList();

//Copy constructor

LList ( const LList & other);

//Overloaded =

const LList & operator= (const LList & other);

//Returns the current length of list

int getLength();

//Returns true if list is empty, false otherwise

bool isEmpty();

// Inserts parameter item in its proper position

void insertItem(T item);

// recursive insert

void insertItem(node *&, T item);

//If list is not empty and parameter item is in the list. If list is //empty or item is not in the list, prints error message

void deleteItem(T item);

//Returns true if parameter item is in the list, false otherwise

bool searchItem(T item);

//Prints all items in the list. Prints error message if list is empty.

void printList(node *);

// dummy print called by client

void printList();

//prints the list in reverse order

void printReverseList (node *p);

void printReverseList ();

//Copies a list

void copy (const LList & other);

//Destroys the list

void destroy();

// Function to return occurrences of item parameter // recursive

int occurrences (T, node *);

// Function to return occurrences of item parameter // non recursive (called by client)

int occurrences (T);

};

#endif

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!