title: C++ unable to use peek() function in stack
body: <p>I am trying to use the <code>peek</code> function in Visual Studio 2010 with these libraries:</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;string&gt;
  #include &lt;string.h&gt;
  #include &lt;fstream&gt;
  #include &lt;iostream&gt;
  #include &lt;string.h&gt;
  #include &lt;vector&gt;
  #include &lt;stack&gt;
  </code></pre>
  
  <p>However, I cannot use the <code>peek</code> function in the stack:</p>
  
  <pre><code>void dfs(){
      stack&lt;Node&gt; s;
      s.push(nodeArr[root]);
      nodeArr[root].setVisited();
      nodeArr[root].print();
      while(!s.empty()){
          //peek yok?!
          Node n=s.peek();        
          if(!n.below-&gt;isVisited()){
              n.below-&gt;setVisited();
              n.below-&gt;print();
              s.push(*n.below);
          }
          else{
              s.pop();
          }
      }
  }
  </code></pre>
  
  <p>I get the error:</p>
  
  <blockquote>
    <p>Error 1 error C2039: 'peek' : is not a member of 'std::stack&lt;_Ty>'</p>
  </blockquote>
  
  <p>What am I doing wrong?</p>