title: I am trying to print Reverse of a Sequence of Numbers using Stack. Stack is implemented using Vector. But I am getting Segmentation Fault
body: <p>Can you please help me find the error in printing the reverse of sequence using stacks implemented by vector?</p>
  <p>I am getting a Segmenattion fault</p>
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  #include&lt;vector&gt;
  using namespace std;
  
  class stack{
      public :
      
      int top; 
      vector&lt;int&gt; data; 
      
      bool isempty(){return top == -1;}
      void push(int x){data[++top] = x;}
      void pop(){--top;}
      int topper(){return data[top];} 
      
  };
  
  
  int main()
  {
      stack s;
      int n; 
      s.top = -1; 
      cout &lt;&lt; &quot;enter the number of integers&quot; &lt;&lt; endl;
      cin &gt;&gt; n; 
      for(int i =0; i &lt; n; i ++){
          s.push(i); 
      }
       while(!s.isempty()){
           cout &lt;&lt; s.topper(); 
           s.pop(); 
       }
       return 0;
  }
  </code></pre>