title: how to check a map is null or not in c++?
body: <p>I am trying to check if a map is empty or not in c++. However, I get a segmentation fault, although the map is not <code>NULL</code>. The code is so simple and here:</p>
  
  <pre><code>void func(std::map&lt;std::string, std::vector&lt;Foo*&gt; &gt;* myMap){
     if(myMap == NULL)
        std::cout &lt;&lt; "My map is Null" &lt;&lt; std::endl;
     else if(myMap-&gt;empty())
        std::cout &lt;&lt; "My map is empty" &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>The parameter sometimes may be an uninitialized map. When I executed this code, the result is a segmentation fault. The code skips the if statement, because it does not see <code>myMap</code> as a <code>NULL</code> map. Then, it crashes in <code>myMap-&gt;empty()</code> command. It also crashes when I try to call any function of the map, such as clear, begin, size, etc. So, if <code>myMap</code> is not <code>NULL</code>, what kind of reason could it cause to this seg. fault?</p>