title: Function in C++ returns by value or by reference?
body: <p>When a function (callee) returns a quantity to the caller function, is it returned by
  value or by reference?</p>
  
  <p>The thing is I have written a function which builds a very large vector of when called. I want to <strong>return</strong> this big vector to the calling function , ( in this case <code>main()</code> ) by constant reference so I can do some further processing on it. </p>
  
  <p>I was in doubt because I was told that when a C++ function returns and terminates, all the variables/memory associated with that function, get wiped clean. </p>
  
  <pre><code>struct node{
  
  string key;
  int pnum;
  node* ptr;
  }
  
  vector&lt; vector&lt;node&gt; &gt; myfun1(/*Some arguments*/)
  {
  
  /*Build the vector of vectors. Call it V*/
  
  return v;
  
  }
  
  int main(void)
  {
  a=myfun1(/* Some arguments */)
  }
  </code></pre>