A sequence class is similar to a bagboth contain a bunch of items, but unlike a bag, the items in a sequence are arranged in an order. In contrast to the bag class, the member functions of a sequence will allow a program to step through the sequence one item at a time. Member functions also permit a program to control precisely where items are inserted and removed within the sequence.
Our sequence is a class that depends on an underlying value_type, and the class also provides a size_type.
Three member functions work together to enforce the in-order retrieval rule:
void start( );
value_type current( ) const; void advance( );
- After activating start, the current function returns the first item
- Each time we call advance, the current function changes so that it returns the next item in the sequence
Provide some additional useful member functions, such as:
- insert_front: insert a new value at the front of the sequence. This new item should now be the current item.
- remove_front: remove the value at the front of the sequence. The new front item should now be the current item.
- attach_back: insert a new value at the back of the sequence. This new item should now be the current item.
- end: The last item in the sequence should now be the current item.
- operator+ and operator+=: These operators should have the precondition that the sum of the sizes of the two sequences being added is smaller than the CAPACITY of a sequence.
Subscript operator:
For a sequence x, we would like to be able to refer to the individual items using the usual C++ notation for arrays. For example, if x has three items, then we want to be able to write x[0], x[1], and x[2] to access these three items. This use of the square brackets is called the subscript operator. The subscript operator may be overloaded as a member function, with the prototype shown here as part of the sequence class:
class sequence { public:
value_type operator [] (size_type index) const;
As you can see, the operator[] is a member function with one parameter. The parameter is the index of the item that we want to retrieve. The implementation of this member function should check that the index is a valid index (i.e., index is less than the sequence size), and then return the specified item.
For this project, specify, design, and implement this new subscript operator for the sequence.

![[Solved] COEN79-Lab 3](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip.jpg)

![[Solved] COEN79-Homework 1](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip-1200x1200.jpg)
Reviews
There are no reviews yet.