title: When return is needed and not needed in C++
body: <p>I did a little experimenting while doing some self taught C++ and found that after removing a return statement from a function, executing my compiled code runs the same. Here's a little example code -- if I were to remove the line</p>
  
  <pre><code>return numb;
  </code></pre>
  
  <p>the code runs just as if it were there</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  class TheClass {
   public:
    int aNumber(int n) {
      numb = n;
      return numb;                                                                                              
    }
    void printOnScreen() {
      cout &lt;&lt; numb &lt;&lt; endl;
    }
   private:
    int numb;
  };
  int main() {
    TheClass exampleObject;
    exampleObject.aNumber(5);
    exampleObject.printOnScreen();
    return 0;
  }
  </code></pre>
  
  <p>Which leads to my question, when is return needed, and when is it not, and also why?</p>