title: Array Implementation of Queue: Strange Output
body: <p>I am learning about queues and I wrote the following program which implements the queue as a linear array (NOT a circular one). </p>
  
  <pre><code>   #include&lt;iostream&gt;
  using namespace std;
  
  class queue {
      int front, max_queue, rear, count = 0;
      int *items;
  public:
      queue(int);
      ~queue();
      void enqueue(int);
      void dequeue();
      bool isEmpty();
      int size();
      void display();
  };
  
  queue::~queue() {
      delete []items;
  }
  
  queue::queue(int max) {
      front = -1;
      rear = -1;
      max_queue = max;
  
      items = new int[max_queue];
  }
  
  void queue::enqueue(int n) {
      if (count == max_queue)
          cout &lt;&lt; "queue is full, no enqueue possible";
      else {
          items[++rear] = n;
          count++;
      }
  }
  
  void queue::dequeue() {
      if (count == 0)
          cout &lt;&lt; "no dequeue possible, queue already empty";
      else {
          front--;
          count--;
      }
  }
  
  bool queue::isEmpty() {
      return ((count == 0) ? 1 : 0);
  }
  
  int queue::size() {
      return count;
  }
  
  void queue::display() {
      if (count == 0)
          cout &lt;&lt; "nothing to display";
      else {
          for (int i = front; i &lt;= rear;)
              cout &lt;&lt; items[i++] &lt;&lt; endl;
      }
  
  }
  
  int main() {
  
      queue *qe = new queue(10);
  
      qe-&gt;enqueue(1);
      qe-&gt;enqueue(2);
      qe-&gt;enqueue(3);
      qe-&gt;enqueue(4);
      qe-&gt;display();
  
  
      return 0;
  }
  </code></pre>
  
  <p>I get the following output</p>
  
  <pre><code>49
  1
  2
  3
  4
  
  RUN FINISHED; exit value 0; real time: 10ms; user: 0ms; system: 0ms
  </code></pre>
  
  <p>Why is there a 49 in my output.? Is it a garbage value? Does not using a circular array implementation,a probable cause? 
  I have no idea. Any help appreciated. </p>