Help with a class

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...

 ``123456789101112131415161718192021222324252627282930313233`` ``````#ifndef DIVSALES_H #define DIVSALES_H #include //DivSales class delcaration class DivSales { private: static double 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 ``````

Source code:

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283`` `````` #include #include #include "DivSales.h" using namespace std; void Q(double, double, double, double); double numQuarters(int); double getTCorpSales(); double DivSales::totalSales; int main () { //V&C DivSales div[6]; double quarter[4]; cout << " ------------------------------------------------------"<> quarter[i]; //Validation while (quarter[i] < 0) { cout << "Please enter a number greater than or equal to 0: "; cin >> quarter[i]; } //storing numbers into div array for future calling div[count1].Q(quarter[0], quarter[1], quarter[2], quarter[3]); } } cout << fixed << showpoint << setprecision(2)<
Last edited on

void Q();
Can you explain? I thought since totalSales was a static variable, it was accessible to all the other functions. More specifically, to:
double getTCorpSales()