title: How would I send values in a vector to a class?
body: <p>I'm assigned to translate an excel spreadsheet into a C++ program.</p>
  
  <p>The excel spreadsheet is a monthly budget report in which the user has to set the cost/income of each of the services he uses, let's say, water, gas, electricity, amazon.com, etc.</p>
  
  <p>After that, the user is asked again to submit the percentage he pays to calculate what he pays individually for each service... I'm somewhat lost in that sentence.</p>
  
  <p>In order to do this, I ask the user to enter the values using a do-while:</p>
  
  <pre><code>double value;
  cin &gt;&gt; value;
  do {
    passToVector(value);
    cin &gt;&gt; value;
  } while(value != 0);
  </code></pre>
  
  <p>The passToVector function then stores the values on an expensesList vector:</p>
  
  <pre><code>void passToVector(double value){
    vector&lt;double&gt; expensesList;
    expensesList.push_back(value);
  };
  </code></pre>
  
  <p>this is where I'm getting lost, the class should be able to receive those values in order to update them when needed. Here it is an example of what my class looks like:</p>
  
  <pre><code>class Expenses {
    private:
      double percentage = 0.00;
      double mortgage = 0.00;
      double electric = 0.00;
      double gas = 0.00;
      double water = 0.00;
    public:
      // Set percentage each person brings
      void setPercentage(double per) { percentage = per; }
      double getPercentage() const { return percentage / 100; }
      // Calculate Total Expenses by Person
      void calculatePersonExpenses() {
        double result = mortgage * getPercentage();
        double result2 = electric * getPercentage();
        double result3 = gas * getPercentage();
        double result4 = water * getPercentage();
  
        cout &lt;&lt; "Mortgage:                      $" &lt;&lt; fixed &lt;&lt; setprecision(2) &lt;&lt; result &lt;&lt; endl;
        cout &lt;&lt; "Electricity:                   $" &lt;&lt; fixed &lt;&lt; setprecision(2) &lt;&lt; result2 &lt;&lt; endl;
        cout &lt;&lt; "Gas(Home):                     $" &lt;&lt; fixed &lt;&lt; setprecision(2) &lt;&lt; result3 &lt;&lt; endl;
        cout &lt;&lt; "Water:                         $" &lt;&lt; fixed &lt;&lt; setprecision(2) &lt;&lt; result4 &lt;&lt; endl;
      }
  };
  </code></pre>
  
  <p>First, I'm assuming I need to create setters and getters for each of the services but if I do that...why would I need a vector function?; right now the only functions that I have are the ones for setPercentage. The task is just to store the values in a Vector of Class Objects data structure.</p>
  
  <p>How can I update those values automatically when I need to?; Do I have to send the values to the class or is my approach totally wrong?</p>
  
  <p>Hopefully I could explain myself.</p>