Hey everyone! I'm having trouble with my program. It runs... but I can't get it to give me the total when I call it. As far as I can tell, it's only totaling one divisions quarterly sales, not all the divisions. I'm at a bit of a loss, so any help is welcome. It's probably something simple and I'm just stuck in the fish bowl and not able to see the issue...
#ifndef DIVSALES_H
#define DIVSALES_H
#include <iostream>
//DivSales class delcaration
class DivSales
{
private:
staticdouble totalSales; //static member variable for total sales
double quarters[4]; //variable to hold quarters
public:
//Gets and stores the quarterly sales, then totals it
void Q(double q0, double q1, double q2, double q3)
{
quarters[0]=q0;
quarters[1]=q1;
quarters[2]=q2;
quarters[3]=q3;
totalSales =+ q0+q1+q2+q3;
}
//accessor function to get quarters
double numQuarters(int quart)
{ return quarters[quart]; }
//accessor function to get total sales for all quarters
double getTCorpSales()
{ return totalSales; }
};
#endif
Can you explain? I thought since totalSales was a static variable, it was accessible to all the other functions. More specifically, to:
double getTCorpSales()
{ return totalSales; }