title: C++ queue inside a class, segmentation fault
body: <p>Can somebody tell, why I have segmentation fault in that code? I have no idea why is that. I use Code:Blocks but online compilers have the same problems. I don't know where the problem is.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;queue&gt;
  #include &lt;memory&gt;
  
  using namespace std;
  
  class Task {   
  private:
      queue &lt;string&gt; q;
      public:
      string input;
      void read (int hm)
      {
          for (int i=1;i&lt;=hm;i++)
          { 
              cin&gt;&gt;input;
              q.push(input);
          }
      }
      void count()
      {
          cout&lt;&lt;q.back();
      }
  };
  
  int main()
  {
      unique_ptr &lt;Task&gt; ptr;
  
      int how_many;
      cin&gt;&gt;how_many;
      ptr-&gt;read(how_many);
      ptr-&gt;count();
      return 0;
  }
  </code></pre>