title: Passing as const and by reference - Worth it?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2139224/how-to-pass-objects-to-functions-in-c">How to pass objects to functions in C++?</a>  </p>
  </blockquote>
  
  
  
  <p>In my game I make excessive use of mathematical vectors and operator overloading of them.</p>
  
  <pre><code>class Vector
  {
     float x, y;
  };
  </code></pre>
  
  <p>That's basically all about my Vector class (methods excluded).</p>
  
  <p>I am not an expert in C++ and I've seen and read about passing as const and passing by reference.</p>
  
  <p>So, where are the performance differences in the below code example?</p>
  
  <pre><code>Float RandomCalculation( Vector a, Vector b )
  {
      return a.x * b.x / b.x - a.x * RANDOM_CONSTANT;
  }
  
  // versus..
  
  Float RandomCalculation( Vector&amp; a, Vector&amp; b )
  {
      return a.x * b.x / b.x - a.x * RANDOM_CONSTANT;
  }
  
  // versus..
  
  Float RandomCalculation( const Vector&amp; a, const Vector&amp; b )
  {
      return a.x * b.x / b.x - a.x * RANDOM_CONSTANT;
  }
  </code></pre>
  
  <ul>
  <li>Which of the three should I use, and why?</li>
  <li><p>What advantages for the optimization process of the compiler does each of the options have?</p></li>
  <li><p>When and where do I have to be especially careful?</p></li>
  </ul>