<1> The specification of Iterafor class
template <Class Item>
class Bag_Iterator() {
public :
Bag_Iterator() ;
vold attach (const Bag <Item>& ) ;
vold adcance() ;
Item current() const ;
bool is_item() const ;
<2> Usage
Bag <Int> foo ;
Bag_Iterator <Int> iterator ;
- - - - - - - - -
for ( iterafor.attach(foo) ; iterator.is_item() ; iterafor.advance() )
cout << iterafor.current() << endl ;
also the following works
Bag_Iterafor <Int> itr1 itr2 ;
for ( itr1.attach(foo) ; itr1.is_item() ; itr(advance() )
for (itr2.attach(foo) ; itr2.is_item() ; itr2.advance() ) {
- - - -
}

a data structer of order entries such that entries can only be insented anol removed at one end (called top)
last-in / first out
- specification (see p309)
- template class :
stacks of integers float
- capcity capcity of stack (fixed-size first)
- member function push : push an item to stack pop : pop on item from stack peek : peek the top item size : obtain the total no of items is.empty : examine if stack is empty
- Stack errors stack underflow : pop from on empty stack stack overfloew : push into a full stack
- documentation (page 309)
apple -> elppa
![]()
![]()
![]()
![]()
![]()