title: C++, using stack.h read a string, then display it in reverse
body: <p>For my current assignment, I have to use the following header file,</p>
  
  <pre><code>#ifndef STACK_H
  #define STACK_H
  
  template &lt;class T, int n&gt;
  class STACK
  {
    private:
      T a[n];
      int counter;
  
    public:
      void MakeStack() {
          counter = 0;
      }
  
      bool FullStack() {
          return (counter == n) ? true : false ;
      }
  
      bool EmptyStack() {
          return (counter == 0) ? true : false ;
      }
  
      void PushStack(T x) {
          a[counter] = x;
          counter++;
      }
  
      T PopStack() {
          counter--;
          return a[counter];
      }
  };
  
  #endif
  </code></pre>
  
  <p>To write a program that will take a sentence, store it into the "stack", and then display it in reverse, and I have to allow the user to repeat this process as much as they want. The thing is, I am NOT allowed to use arrays (otherwise I wouldn't need help with this), and am finding myself stumped.</p>
  
  <p>To give an idea of what I am attempting, here is my code as of posting, which obviously does not work fully but is simply meant to give an idea of the assignment.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstring&gt;
  #include &lt;ctime&gt;
  #include "STACK.h"
  using namespace std;
  
  int main(void)
  {
      auto time_t a;
      auto STACK&lt;char, 256&gt; s;
      auto string curStr;
      auto int i;
  
      // Displays the current time and date
      time(&amp;a);
      cout &lt;&lt; "Today is " &lt;&lt; ctime(&amp;a) &lt;&lt; endl;
  
      s.MakeStack();
      cin &gt;&gt; curStr;
      i = 0;
      do
      {
          s.PushStack(curStr[i]);
          i++;
      } while (s.FullStack() == false);
  
      do
      {
          cout &lt;&lt; s.PopStack();
      } while (s.EmptyStack() == false);
  
      return 0;
  } // end of "main"
  </code></pre>
  
  <p><strong>UPDATE</strong>
  This is my code currently</p>
  
  <pre><code>#include   &lt;iostream&gt;
  #include   &lt;string&gt;
  #include   &lt;ctime&gt;
  #include   "STACK.h"
  using namespace std;
  
  time_t                      a;
  STACK&lt;char, 256&gt;        s;
  string             curStr;
  int                     i;
  int                     n;
  
  // Displays the current time and date
  time(&amp;a);
  cout &lt;&lt; "Today is " &lt;&lt; ctime(&amp;a) &lt;&lt; endl;
  
  s.MakeStack();
  getline(cin, curStr);
  i = 0;
  n = curStr.size();
  do
  {
     s.PushStack(curStr[i++]);
      i++;
  }while(i &lt; n);
  
  do
  {
      cout &lt;&lt; s.PopStack();
  }while( !(s.EmptyStack()) );    
  
  return 0;
  </code></pre>