1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

//See Stacks/stack2.cc

#include <iostream.h>
#include "mydefs1c.h"

void main()
{
// creator called 5 times for s4
Istack s1(500), s2, s4[5]; Istack* s5;
int i;

s5 = new Istack;// get stack space for( i = 0; i < 20; i++ ) {
s1.push(i);
// 500 element stack }
for( i = 0; i < 20; i++ ) {
cout << s1.pop() << ' ';
}
cout << endl;

s2.push(10);// default stack cout <<s2.pop() << ' ';
s4[4].push(11);
// 4th stack in the array cout << s4[4].pop() << ' ';
s5->push(12);
// pointing to a stack cout << s5->pop() << endl;
delete s5;
// explicit removal }

*Using just one constructor as before say,
Istack( int Nitems = 100 ),
works for everything, but for the array declaration
Istack ... s4[5],
the default constructor Istack() is called 5 times.

See Stacks/stackmain1c.cc for more complete example

16-Mar-98

Page 11

C201/TAM/AGS