title: what is the difference returning const or non-const in primative types c++
body: <p>I've tried to understand what differs if I add const or ignore it while returning function. Let me explain my question through an example.</p>
  
  <pre><code>const int foo()
  {
      return 3;
  }
  
  int main()
  {
      int check;
      check=foo();
      cout&lt;&lt;"before:"&lt;&lt;check&lt;&lt;endl;
      check=1;
      cout&lt;&lt;"after:"&lt;&lt;check&lt;&lt;endl;
      return 0;   
  }
  </code></pre>
  
  <p>Up to now, I always think that, since I write const foo() I dont be able to change the check varaible,however I compiled it and get no error. </p>
  
  <p>I wonder what I gain or loose by writing const before my foo() function.</p>
  
  <p>Thanks in advance</p>