title: c++ Multiple functions referring to same variables
body: <p>I am working through exercises in a book to get familiar with user defined functions and working with files. In this particular exercise, I am to use the functions as I have them listed to find the average test scores of male and female students separately. They will be read from an existing file. When I started writing the function prototypes I have all these different names to reference the same variables in main. As far as I know, the book discourages using the same variables in different functions. So, my question is, is this overkill, sloppy, or good practice?</p>
  
  <p>UPDATE:
  To clarify what I mean by 'referencing the same variables'...</p>
  
  <p>In main I have a variable called maleScoreSum which is a variable to hold the sum of the male test scores. This variable is referenced in three functions so far. It's sumM in the function initialize, Msum in the next function, and mSum in the function after that. Is this the correct way to do this? Would it be okay (or better) if all the functions used something like maleSum to reference the variable in main? I'm almost to the end of the structured programming section of the book and haven't got to the OOP section with classes and such yet. Also, so far, none of the practice programs allow the use of global variables. </p>
  
  <p>Prototypes:</p>
  
  <pre><code>void openFile(ifstream&amp; inDat, ofstream&amp; outDat);
  void initialize(int&amp; countF, int&amp; countM, double&amp; sumF, double&amp; sumM, double&amp; avgF, double&amp; avgM);
  void sumGrades(ifstream&amp; inDat, double&amp; Fsum, double&amp; Msum);
  void averageGrade(int&amp; fCount, double&amp; fSum, int&amp; mCount, double&amp; mSum);
  void printResults(int fAvg, int mAvg);
  </code></pre>
  
  <p>Variables in Main:</p>
  
  <pre><code>    ifstream inData;
  ofstream outData;
  int no_of_females;
  int no_of_males;
  double maleScoreSum;
  double femaleScoreSum;
  double maleAverage;
  double femaleAverage;
  </code></pre>
  
  <p>I've also noticed when I hit ctrl K and paste code I can only paste one line at a time. Thanks for any help.</p>