Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are to implement a 'List' class in C++ to handle a list with general operations. That means you can insert and delete any element

You are to implement a 'List' class in C++ to handle a list with general operations. That means you can insert and delete any element anywhere in the list. The list has no order, except for the order you insert or delete. The methods you are to implement are as given:

Constructor methods (two, default and copy constructor, a list to a newly defined list, ie 'List listA(listB)' )

empty returns true or false if list is empty or not.

front makes current position at the beginning of the list

end makes current position at the end of a list.

prev places current position at the previous element in the list

next places current position at the next element in the list

getPos returns current position or where you are in the list

setPos(int) places current position in a certain position in the list

insertBefore inserts a new element before the current position

insertAfter inserts a new element after the current position

get Element returns the one element that current position is pointing to

size returns the size of the list (number of elements in list)

replace(int) replace the current element with a new value

erase deletes the current element

clear makes the list an empty list

reverse reverse elements in a list

swap swaps all the elements of one list with the another list.

overload the operators: (at least) << output, == , + , = (assignment)

You are to implement the List class using an array. For now the array can be 20 in size.

You will need to use the 'ElementType' for 'typing' your data.

You will need to use CAPACITY constant for the size of the array, in case we need to change the array size.

Invariants: The elements in the list should be left justified. pos should point to the element just inserted. pos should never be outside of element list.

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

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions