Question
Using the circular linked list specification here, implement the class constructor and destructor in c++ template struct Node; // forward reference /* Given: T is
Using the circular linked list specification here, implement the class constructor and destructor in c++
template
struct Node; // forward reference
/* Given: T is a type for which the operators "<" and "==" are defined either
an appropriate built-in type or a class that overloads these operators */
template
class Sorted
{
public:
// class constructor, destructor, and copy constructor
Sorted();
~Sorted();
Sorted(const Sorted
void operator=(Sorted
bool IsFull() const; // Determines whether list is full
// Post: Function value = (list is full)
int GetLength() const; // Determines number of elements in list
// Post: Function value = number of elements in list
// the following operations have the pre/post
// condition that the list items are sorted
void RetrieveItem(T & itm, bool & found);
// gets list element whose key matches item's key, if present
// Pre: Key member of item is initialized
// Post: If there is an element someItem whose key matches
// item's key, then found = true and item is a copy of
// someItem; otherwise found = false and item is unchanged
// List is unchange
void InsertItem(T itm); // adds itm to list
// Pre: List is not full; itm is not in list
// Post: itm is in list
void DeleteItem(T itm);
// deletes the element whose key matches itm's key
// Pre: Key member of itm is initialized;
// One and only one element in list has a matching key
// Post: No element in list has a key matching itm's key
void ResetList();
//initializes current position for an iteration through list
// Post: Current position is prior to list
void GetNextItem(T & itm); // gets the next element in list
// Pre: Current position is defined;
// Element at current position is not last in list
// Post: Current position is updated to next position
// item is a copy of element at current position
private:
Node
int length;
Node
};
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started