title: Very confused regarding professor's instructions on classes and class parameters - Intro to C++ course
body: <p>We just started learning classes in this intro c++ CS class. I'm including much of the prompt for this project just in case it is helpful to answering my question, but I bolded the lines that I have specific questions on.</p>
  
  <blockquote>
    <p>Declare and define a class called Odometer. This class will have two
    private variables, one for the miles driven and the other for the
    gallons of gas pumped into the car. We are going to assume that the
    car starts with a full tank, but these values begin at zero in the
    default constructor. The member functions should include: </p>
    
    <p>• A constructor that takes initial values for both of the private
    variables. </p>
    
    <p>• A default constructor that sets both values to zero.</p>
    
    <p>• A get_miles function </p>
    
    <p>• A get_gallons function </p>
    
    <p>• <strong>An add_in_trip_miles function which increases the miles by the amount sent in its parameter</strong></p>
    
    <p>• <strong>An add_gas function that records how much gasoline was pumped into
    the tank.</strong> </p>
    
    <p>• A mpg function that returns the number of miles per gallon
    for the miles driven and the total amount of gas added to the tank.</p>
    
    <p>• A reset function which resets the miles and the gallons to zero.</p>
    
    <p>Write the class declaration at the top of your program and the
    function definitions at the bottom. In the middle write a main which
    declares an odometer object and then offers the user a menu n a loop
    to allow them to chose to</p>
    
    <ol>
    <li>See total miles</li>
    <li>See total gallons</li>
    <li>Record more miles driven</li>
    <li>Record gallons pumped into the tank</li>
    <li>See the average mpg that the car has gotten – this is a cumulative number based on the total number of miles driven and gallons pumped
    into the tank since the odometer was lat reset, or the object created</li>
    <li>Reset the odometer</li>
    <li>Quit the program</li>
    </ol>
  </blockquote>
  
  <p>So the two functions bolded essentially do the same thing, one increases how many miles have been driven and the other increases how many gallons of gas into the tank, both by user-inputed values. My question towards my professor, then, was why does the miles function require data sent into the parameter, while the gallons function does not? They are essentially the same, so I'm confused as to why they shouldn't either both pass a parameter, or neither pass one. Here are the those two functions in my code:</p>
  
  <pre><code>void Odometer::add_in_trip_miles(){
      double milesToAdd;
      cout &lt;&lt; "How many miles would you like to add to the total?" &lt;&lt; endl;
      cin &gt;&gt; milesToAdd;
      milesDriven += milesToAdd;
  }
  
  void Odometer::add_gas(){
      double gallonsToAdd;
      cout &lt;&lt; "How many gallons would you like to add to the total?" &lt;&lt; endl;
      cin &gt;&gt; gallonsToAdd;
      gallonsGas += gallonsToAdd;       
  }
  </code></pre>
  
  <p>Currently the first one doesn't meet the project prompt, since it doesn't pass the value in the parameter, it just uses cout/cin in the function itself to get the value to add to the total. I figured i could meet the prompt by just putting the cout/cin in the int main(), and passing that value into the <code>add_in_trip_miles</code> function. </p>
  
  <p>I emailed him about the confusion, and got the following response, which left me even more confused:</p>
  
  <blockquote>
    <p>There's a difference between input/output functions, which get
    information from the keyboard/input-file or output information to the
    screen/output file, and the set functions. I programmer can use the
    set functions if they would like to do their own user interaction, or
    if they are getting the information to be put into the object from
    somewhere else - perhaps a calculated value.I was hoping that you
    would implement both, which is what we usually do when we write a
    class so as to give the application programmer the options.</p>
  </blockquote>
  
  <p>Is he just asking for more functions that are input/output functions only, that then pass those input functions into <code>add_in_trip_miles</code> and <code>add_gas</code>? This email left me even more confused, since he mentioned (in the project prompt, above) each member function that was needed, and none of them are input functions. </p>
  
  <p>Any guidance here would be great, my code currently does exactly what he wants it do to, but I don't want to be penalized because I didn't use functions in a certain way, etc. Let me know what you guys think and thanks for any help!</p>