[Solved] [C++} Not sure if this is even possible


You’ll probably need a vector like Soren mentioned. If you’re trying to get some averages for all employees (which that’s what I assume you’re trying to do), then let’s say we’re going to try and get an average for gross pay.

You’ll need a vector global, like such:

#include <iostream>
#include <fstream>
#include <iomanip>
#include <vector>
using namespace std;

vector<double> netPayList;
double globalAverage;

You’ll then need to add information to the vector when GrossPay is calculated as such:

void employee::calculateNetpay() 
{
     netpay = grosspay - taxamount;

     netPayList.push_back(netpay);    
}

Finally, we can calculate the average in employee::findAverage(), we should also probably use a for loop for this as well, and in my opinion we should ditch the public function of “employee” and switch that over to a traditional function, since we are trying to get the average for many “employee” instances. The average calculation will now look like this:

double findAverage()
{
        for (int iterator = 0; iterator < netPayList.size(); iterator++)
        {
             average += netPayList[iterator];
        }

        globalAverage /= netPayList.size();

        return globalAverage;
 }

Anyway, that’s basically the gist of it. Keep working on your stuff, but also I would suggest that you title your questions better. Someone with more gumption and SO privileges than I will most likely edit your OP.

1

solved [C++} Not sure if this is even possible