title: Is it always better to use pass by reference in C++?
body: <blockquote>
    <p><strong>Possible Duplicates:</strong><br>
    <a href="https://stackoverflow.com/questions/1567138/const-t-arg-vs-t-arg">&ldquo;const T &amp;arg&rdquo; vs. &ldquo;T arg&rdquo;</a><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>I used the following code to ascertain that C++ on passing objects as const reference the compiler does not make a copy of the object and send the copy. The output confirmed that passing object as const reference does not involve making a copy of the object.</p>
  
  <p>Is there any situation in which passing objects as reference is worse than passing objects as value ( from an efficiency perspective ) ?</p>
  
  <pre><code>class ABC { 
  
  public:
  
    int abc_1;
    int abc_2;
  
  };
  
  void swapABC ( ABC &amp; _abc_ ) {
  
    _abc_.abc_2 = ( _abc_.abc_1 + _abc_.abc_2 ) - ( _abc_.abc_1 = _abc_.abc_2 ) ;
  
    printf ( "%d\n", ( void * ) &amp;_abc_ ) ;
  
  }
  
  int main ( ) {
  
    ABC x = { 1,2 };
    swapABC ( x );
    printf ( "%d\n", ( void * ) &amp;x ) ;
  
    return 0;
  
  }
  </code></pre>