// stackdr.cpp in StackType3.   very similar to StackType2/

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

using namespace std;

struct thingee {    //example struct
  int i;
  char c;
  float f;
};

void f();


int main() {

  f();
  cout << "bye from main" << endl;
}


void f() {
  StackType<int> s1;       //will use default ctor (stack of up to 500 ints)
  StackType<char> s2(5);   //stack of up to 5 chars
  StackType<thingee> s3(100);  //stack of up to 100 thingees
  int num;
  char ch;
  thingee t;


  // int stack
  cout << "Enter numbers, negative number to stop" << endl;
  do {
    cin >> num;
    if (num >= 0)
      s1.Push(num);
  } while (num >= 0);

  cout << endl << "The numbers in reverse order are:" << endl;

  while (!s1.IsEmpty()) {
    s1.Pop(num);
    cout << num << "  ";
  }
  cout << endl << endl;
  cout << "----------------------------------------------------------" << endl;


  // char stack
  cout << "Enter characters, pound sign (#) to stop" << endl;
  do {
    cin >> ch;
    if (ch != '#')
      s2.Push(ch);
  } while (ch != '#');

  cout << endl << "The characters in reverse order are:" << endl;

  while (!s2.IsEmpty()) {
    s2.Pop(ch);
    cout << ch << "  ";
  }
  cout << endl << endl;
  cout << "----------------------------------------------------------" << endl;


  // thingee stack
  cout << "Enter thingee records (int, char, float), negative number to stop" << endl;
  do {
    cin >> t.i >> t.c >> t.f;
    if (t.i >= 0)
      s3.Push(t);
  } while (t.i >= 0);

  cout << endl << "The thingees in reverse order are:" << endl;

  while (!s3.IsEmpty()) {
    s3.Pop(t);
    cout << t.i << "  " << t.c << "  " << t.f << endl;
  }
  cout << endl;
  cout << "----------------------------------------------------------" << endl;

  //destructors of the local stack objects will be automatically called here
}





