title: Trying to return multiple values
body: <p>I'm having some trouble returning multiple values in this program that calculates min, max, mean, median. The first thing I did was pass reference arguments, and it worked - but I read that creating a struct or class is the preferred method to returning multiple values.</p>
  
  <p>So I tried and I haven't been able to get good results. Here is what I've got so far.</p>
  
  <pre><code>#include "std_lib_facilities.h"
  struct maxv{
         int min_value;
         int max_value;
         double mean;
         int median;
  };
  
  maxv calculate(vector&lt;int&gt;&amp; max)
  {
  
      sort(max.begin(), max.end());
  
      min_value = max[0];
  
      int m = 0;
      m = (max.size()-1);
      max_value = max[m];
  
      for(int i = 0; i &lt; max.size(); ++i) mean += max[i];
      mean = (mean/(max.size()));
  
      int med = 0;
      if((max.size())%2 == 0) median = 0;
      else
      {
          med = (max.size())/2;
          median = max[med];
          }
  
  }
  
  int main()
  {
      vector&lt;int&gt;numbers;
      cout &lt;&lt; "Input numbers. Press enter, 0, enter to finish.\n";
      int number;
      while(number != 0){
                   cin &gt;&gt; number;
                   numbers.push_back(number);}
      vector&lt;int&gt;::iterator i = (numbers.end()-1);
      numbers.erase(i);
      maxv result = calculate(numbers);
      cout &lt;&lt; "MIN: " &lt;&lt; result.min_value &lt;&lt; endl;
      cout &lt;&lt; "MAX: " &lt;&lt; result.max_value &lt;&lt; endl;
      cout &lt;&lt; "MEAN: " &lt;&lt; result.mean &lt;&lt; endl;
      cout &lt;&lt; "MEDIAN: " &lt;&lt; result.median &lt;&lt; endl;
      keep_window_open();
  }
  </code></pre>
  
  <p>Obviously the variables in the calculate function are undeclared. I'm simply not sure how to implement this in the correct way to return the correct values. So far from the things I've tried, I've gotten VERY construed values. Any help would be appreciated - thanks.</p>
  
  <p>P.S. I've looked at other threads regarding this topic and I'm still kind of confused since there aren't really any differences between the arguments that need to be passed to calculate() and the variables in the maxv struct.</p>