title: Why does this case statement need an "if else" and not just an "if"?
body: <p>So I am new to C++, and I am working through a pdf tutorial that is getting me started with basic stuff. I was writing a simple case program, and I experienced something weird.</p>
  <pre><code>#include &quot;pch.h&quot;
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  enum string_feeling {
      eGood,
      eBad,
      eOk,
  };
  
  string_feeling hashit(string const&amp; feeling) {
      if (feeling == &quot;Good&quot; || feeling == &quot;good&quot; || feeling == &quot;GOOD&quot;) {
      return eGood;
      }
      if (feeling == &quot;Bad&quot; || feeling == &quot;bad&quot; || feeling == &quot;BAD&quot;) {
          return eBad;
      }
      if (feeling == &quot;Ok&quot; || feeling == &quot;ok&quot; || feeling == &quot;OK&quot;) {
          return eOk;
      } 
      else cout &lt;&lt; &quot;&quot;;
  }
  
  int main() {
      string username;
      cout &lt;&lt; &quot;Hello! Please enter your first name here: \n&quot;;
      cin &gt;&gt; username;
      cout &lt;&lt; &quot;Hello, &quot; &lt;&lt; username &lt;&lt; &quot;!\n&quot;;
      cout &lt;&lt; &quot;How are you today? &quot;;
      string feeling;
      cin &gt;&gt; feeling;
      cout &lt;&lt; endl;
  
      switch (hashit(feeling)) {
      case eGood:
          cout &lt;&lt; &quot;That's great!&quot;;
          break;
      case eBad:
          cout &lt;&lt; &quot;I hope you are happy soon!&quot;;
          break;
      case eOk:
          cout &lt;&lt; &quot;That's good.&quot;;
          break;
      default:
          cout &lt;&lt; &quot;Ok.&quot;;
      }
  }
  </code></pre>
  <p>Whenever I didn't have the &quot;else&quot; after the &quot;if (feeling == ok)&quot; stuff, the default case would never be called and if I entered something random it would give me the text from the eGood case. I was wondering why this is happening and since I'm learning C++ I didn't want to just brush it off not ever knowing why it worked after I put the else statement in there. So, if anyone could explain this to me that would be great! Sorry for my bad grammar.</p>