The insert and attach member functions. There are two member functions to
add new items to a sequence. One of the functions, called insert, places a new
item before the current item. For example, suppose that we have created the
sequence shown to the right with three items, and that the current item is 8.8. In
this example, we want to add 10.0, immediately before the current item. When
10.0 is inserted before the current item, other items—such as 8.8 and 99.0—will
move down to make room for the new item. After the insertion, the sequence has
the four items shown in the lower box.
If there is no current item, then insert places the new item at the front of the
sequence. In any case, after the insert function returns, the newly inserted item
will be the current item, as specified in this precondition/postcondition contract:
methods are:
void insert(const value_type& entry);
void attach(const value_type& entry);
a) You didn't post what attach function should do.
b) You didn't post class where you want implement these function.
Because I would implement these like:
};
this is class
a) attach function:
void attach(const value_type& entry);
// Precondition: size( ) < CAPACITY.
// Postcondition: A new copy of entry has been inserted in the sequence
// after the current item. If there was no current item, then the new entry
// has been attached to the end. In either case, the new item is now the
// current item of the sequence.