Question: I have a bug in my code in SortedListProgram.cpp on line 11. It says its undefined. can you help me fix it? Heres the instructions
I have a bug in my code in SortedListProgram.cpp on line 11. It says its undefined. can you help me fix it? Heres the instructions and my code.
LAB 17.2 Sorted List
Use the following declaration on file sortedList.h for these exercises. Read the documentation of the member function declarations carefully.
----------------------------------------------------------------------------------------------
#include
const int MAX_ITEMS = 20;
typedef string ItemType;
class SortedList
{
public:
SortedList ();
// Constructor
// Post: Empty list is created.
// Action responsibilities
void Insert(ItemType item);
// Pre: The list is not full;
// Post: item is in the list; list is stored in
// increasing order.
void PrintList();
// Post: If the list is not empty, the elements are
// printed on the screen in increasing order;
// otherwise "The list is empty" is
// printed on the screen.
// Knowledge responsibilities
int GetLength();
// Post: return value is the number of items in the list.
bool IsEmpty();
// Post: returns true if list is empty; false otherwise.
bool IsFull();
// Post: returns true if there is no more room in the
// list; false otherwise.
private:
int length;
ItemType values[MAX_ITEMS];
};
---------------------------------------------------------------------------------------------
Exercise 1: The name of the member function that puts an item in the list has changed from Store to Insert. Explain why.
Exercise 2: Compare the specifications of classes ListWithDuplicates and SortedList. How are they alike? How are they different?
Exercise 3: Write the definitions for the member functions. Save the code in file sortedList.cpp.
Exercise 4: Write a driver program that reads values from file word.in, stores them in the list, and prints them on the screen. Be sure that your driver adheres to the preconditions on the member functions. What are the last four values in the file?
Sample Run:

//SortedListProgram.cpp
#include "sortedList.h"
#include
#include
using namespace std;
int main()
{
string value;
SortedList list;
list.PrintList();
ifstream file("word.in");
if (file.good())
{
while (getline(file, value))
{
list.Insert(value);
}
file.close();
}
list.PrintList();
return 0;
}
Sortedlist.cpp
//#include "stdafx.h"
#include "sortedList.h"
#include
#include
#include
using namespace std;
SortedList::SortedList()
{
length = 0;
}
bool SortedList::IsEmpty()
{
if (values->empty())
return true;
return false;
}
bool SortedList::IsFull()
{
if (length == MAX_ITEMS)
return true;
return false;
}
void SortedList::Insert(ItemType item)
{
if (!IsFull())
{
values[length] = item;
++length;
sort(values, values + length);
}
}
void SortedList::PrintList()
{
if (IsEmpty())
{
cout
}
else
{
for (int index = 0; index
{
cout
}
cout
}
}
int SortedList::GetLength()
{
return length;
}
CAUsersleleel DesktoplCPSC230-Testi Debug1CPSC230.exe The items in the array are: BlueJay Cardinal Dove Eagle Grackle Grackle HummingBird Robin SandPiper SeaGul1 Seagull SkyHawk Sparrow Starling Wren andpiper There are 18 items in the list. Press any key to continue
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
