title: why "return 0" works for returning a pointer in function, but not works for reference?
body: <p>edit on Feb 25: changed my question, and adding some describes to my question.</p>
  
  <p>======================some complains===========================</p>
  
  <p><strong>To those people who down-vote my question:</strong></p>
  
  <p>This is my first question on stack-overflow.</p>
  
  <ol>
  <li>about the question: this question was emerged from my thought. in my case, I thought the <code>return 0</code> actually did something for my
  program, and it absolutely did. The only thing could misunderstand
  people is probably I gave a question that I think it works like that
  way but it didn't.</li>
  <li>about my attitude. Maybe you guys here are expert in C++ and you might think my question is stupid. However, as a non-English-native speaker, this question is took me 4 hours to think and do the test, 2 hours for searching on google but also took me at least half hour to post. As a self-taught newbie I already tried my best to make the question as best as I could.</li>
  </ol>
  
  <p>Thus, please at least leave a comment to let me know what I could improved about the way I submit my question, when you do the downvote. Do not just make a simple click. Your click is just like a new question to make me consider： "am i did something wrong?" "how could I solve it?" It is going to force me to reconsider what I’ve done; but just like the normal questions, It would be help if someone could give some tips.</p>
  
  <p>As a newbie, I won't stop to raise questions; so I think point out my problems will help me to improve my ability to raise high quality questions, and you will benefit also because you might see some good questions in future.  </p>
  
  <p>At last, thanks again for this place; I got a lot answers from here; And also thanks for those people who helped me to solved my problem.</p>
  
  <p>=======================question line======================</p>
  
  <p>This function I intend to get an array argument by using "using alias form", and trying to return the array itself back to the calling function. I tried to use pointer and reference both for this function.</p>
  
  <p>here is what I learned from C++ primer:</p>
  
  <pre><code>using arrT = int[10];
  arrT* func(int i);
  </code></pre>
  
  <p>This code is suppose to define a function that would return a pointer that point to a array with ten ints; I understand this, but I didn't get a example from book.</p>
  
  <p>and here are my tries:</p>
  
  <p>using pointer, trying to return the pointer directly, but error.</p>
  
  <pre><code>arrT* return_p(arrT arr){
      for(int i = 0; i &lt; 10; ++i){
          *(arr+i) *= 2;
      }
      return arr;//error, can't convert int* to int (*)[10]
  }
  </code></pre>
  
  <p>i know because here <code>arr</code> is converted and lost the array's dimension. However, I just found a way that works for me:</p>
  
  <pre><code>arrT* return_p(arrT arr){
      for(int i = 0; i &lt; 10; ++i){
          *(arr+i) *= 2;
      }
      return 0; // return 0 is return pointer arr that point the first element of array arr.
  }
  </code></pre>
  
  <p>I just wondering how did the <code>return 0</code> work here? And I do have another result here if I use reference instead of using pointer:</p>
  
  <pre><code>arrT&amp; return_r(arrT &amp;arr){
      for(auto &amp;i : arr){
          i *= 2;
      }
      return arr; // works, returned the reference to array named arr
  }
  </code></pre>
  
  <p>but <code>return 0</code> is not working for the reference version.</p>
  
  <pre><code> arrT&amp; return_r(arrT &amp;arr){
      for(auto &amp;i : arr){
          i *= 2;
      }
      return 0; // error, using an int rvalue to initialize a non_const that has type int(&amp;)[10];
  }
  </code></pre>
  
  <p>I hope I told my question clearly. thanks for your help!</p>