according to the output expected my program works fine except on the last line where the limit is supposed to be 3. My output shows 0, where am I going wrong???
The output is here http://www.cs.uh.edu/~svenkat/lib/as...ASSIGN1/output
the main.cpp for the .h and its accompanying .cpp is here http://www.cs.uh.edu/~svenkat/lib/as...N1/assign1.cpp .
The .h file
Code:
class ModuloCounter
{
public:
ModuloCounter(int );
ModuloCounter(const ModuloCounter& theCounter);
~ModuloCounter();
void increment (void);
void decrement (void);
static int getNumberofModuloCounters(void);
int getCounterLimit(int)const;
int getCounterValue(void)const;
private:
int modLim;
int currVal;
static int modCount;
};
.cpp file
Code:
#include "ModuloCounter.h"
int ModuloCounter::modCount=0;
ModuloCounter::ModuloCounter(int set)
{
modLim=set;
currVal=1;
modCount++;
}
ModuloCounter::~ModuloCounter()
{
modCount--;
}
void ModuloCounter::increment(void)
{
if(currVal==modLim)currVal=1;
else currVal++;
}
void ModuloCounter::decrement(void)
{
if(currVal==1)currVal=modLim;
else currVal--;
}
int ModuloCounter:: getNumberofModuloCounters(void)
{
return modCount;
}
int ModuloCounter:: getCounterLimit(int limit)const
{
limit=modLim;
return limit;
}
int ModuloCounter:: getCounterValue(void)const
{
return currVal;
}
ModuloCounter::ModuloCounter(const ModuloCounter& theCounter)
{
currVal=theCounter.currVal;
modCount++;
modLim=theCounter.modLim;
}