title: if statement and segmentation fault - c++
body: <p>I have an if/else if statement that looks like this:</p>
  
  <pre><code>if(myNode-&gt;left-&gt;is_red){
      //CODE TO EXECUTE
  }               
  else if(myNode-&gt;right-&gt;is_red){
      //CODE TO EXECUTE
  }
  </code></pre>
  
  <p>The conditions I am checking are whether certain data fields in each node are set. BUT, the problem is, if I access a NULL pointer and try to access its members (which don't exist), then I run into a segmentation fault issue. But if I do an if statement before the if, and again before the else if, to check whether or not the node is NULL, then I lose the ability to use an if/else if statement.</p>
  
  <p>Is there any way I can achieve a solution to both problems?</p>