title: invalid initialization of non-const reference of type ‘std::vector<double>&’ from an rvalue of type
body: <p>I am learning c++ and trying some things. The compiler is not throwing an error at comment 2 line.  </p>
  
  <pre><code>int main(){
     vector&lt;double&gt; a1;
     a1.push_back(3);
     a1.push_back(7);
     a1.push_back(2);
     vector&lt;double&gt;&amp; a2 = a1;          //COMMENT 1: This line has no error
     vector&lt;double&gt;&amp; a4 = print(a2);   //COMMENT 2: Why this line has error? R value is an object then it should be referenced by a4? 
     return 0;
  }
  
  vector&lt;double&gt; print(vector&lt;double&gt;&amp; a3){
     cout&lt;&lt;"In print function the size of vector is :";
     cout&lt;&lt;a3.size()&lt;&lt;endl;
     return a3;
  }
  </code></pre>