Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the following skeleton of an unsorted list class that uses an unsorted linked list: #define MAXITEM 100 typedef float ItemType; class List { public:

Given the following skeleton of an unsorted list class that uses an unsorted linked list:

#define MAXITEM 100

typedef float ItemType;

class List

{

public:

List(); // default constrctor

List(const List &x); // copy constructor with deep copy

bool IsThere(ItemType item) const; // return true of false to indicate if item is in the

// list

void Insert(ItemType item); // if item is not in the list, insert it into the list

void Delete(ItemType item); // delete item from the list

void Print(); // Print all the items in the list on screen

int Length(); // return the number of items in the list

~List(); // destructor: programmer should be responsible to set the value of all the array elements to zero

List & operator = (const List &x); // overloading the equal sign operator

private:

int length;

ItemType info[MAXITEM];

};

Task 1: Implement the class List on the basis of the above skeleton. Compile your program.

Task 2: Write a simple driver that inserts the following numbers sequentially into the list:

3.5

2.1

6.8

4.3

7.5

0.2

The insertion should be done by calling the member function Insert( ). For instance,

List a;

a.Insert(3.5);

a.Insert(2.1);

..

Prints the length of the final list, and prints the items.

Task 3: Add code to your driver to test the remaining member functions. Delete

4.3 from the list. For instance,

a.Delete(4.3);

Then print the list to demonstrate that the number is gone.

Task 4: How do you test the copy-constructor and the = operator ? Design a segment of code to test these two in your main( ).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 27th International Conference Dasfaa 2022 Virtual Event April 11 14 2022 Proceedings Part 2 Lncs 13246

Authors: Arnab Bhattacharya ,Janice Lee Mong Li ,Divyakant Agrawal ,P. Krishna Reddy ,Mukesh Mohania ,Anirban Mondal ,Vikram Goyal ,Rage Uday Kiran

1st Edition

3031001257, 978-3031001253

More Books

Students also viewed these Databases questions