This seems like bad coding practice, but it was the guidelines given to me. I want to preface by saying I have no idea how this will actually be implemented in the main, Im just writing the class.
class Example
{
private:
static int total;
public:
void initalizeTotal();
}
Example::initalizeTotal()
{
total = 0;
}
total will (I guess) be used to count the number of objects of that class. This is basically what I'm getting at. The problem is how I figure out how to actually call the function. I can't just call it in the constructor, sense that would reset total each time. And I've tried and failed "check" if the variable has a value yet and if not, call the function.
Is there any advice anyone can give?
EDIT: I forgot to include that total is static. And that i MUST have a function that initializes total. Thats a requirement of the assignment.