title: Passing argument by reference; does the function return type HAVE to be void?
body: <p>I've recently started to learn C++ and now I'm learning about passing arguments to functions. Knowing there are two methods of doing so, I've made a simple code of doubling a number given by the user.</p>
  
  <p>My first question is,
  When passing an argument to a function through reference, MUST that function be a <code>void</code> type or can it be an <code>int</code> too?</p>
  
  <p>I ask this question because most of the examples I've seen have been using void.</p>
  
  <p>Second question is my code,</p>
  
  <pre><code>
      #include &lt;iostream&gt;
  
  
      //using std::cout;
      //using std::cin;
      //using std::endl;
  
  
      using namespace std;
  
  
      int doubleByValue(int value){       //this is the function which takes the argumrnt passed down by main as a Value
          int Doubled;
          Doubled = value * value;
  
          return Doubled;
      }
  
      /*
      int doubleByReference(int &amp;value){      //This is the function which takes the argument passed from main as a Reference
          value = value * value;
  
          return value;
      }
      */
  
      void doubleByReference(int &amp;value){     //This is the function which takes the argument passed from main as a Reference
          value = value * value;
  
      }
  
  
      int main(){
          cout &lt;&lt; "In this program we would be doubling the values entered by the user" &lt;&lt; endl;
          cout &lt;&lt; "using the two methods of passing arguments, through value and by reference." &lt;&lt; endl;
  
  
          int Number = 0;
          cout &lt;&lt; "Please enter a Number: ";
          cin &gt;&gt; Number;
  
  
          cout &lt;&lt; endl &lt;&lt; "Number doubled after passed by Value: " &lt;&lt; doubleByValue(Number) &lt;&lt; endl;
          cout &lt;&lt; endl &lt;&lt; "Number doubled after passed by Reference: " &lt;&lt; doubleByReference(Number) &lt;&lt; endl;
  
          return 0;
      }
  
  </code></pre>
  
  <p>My top method, i.e the passing an argument through value method works completely fine.</p>
  
  <p>But, I've used two methods to pass an argument by reference, by which the type <code>int</code> function works completely fine (This is the one I've commented) but I get a ton of errors or warnings for the second one. Why is that happening? because there's not much of a difference between the two I really don't understand how could there be such big errors or warnings for this.</p>
  
  <p>I notice the program still runs so I'm guessing it's just warnings.</p>