Hi, i have made the .h and .cpp file for an assignment, but upon compiling i get a "illegal call of non-static member function". Why is this happening Thanks in advance for the help ......ALso another question, do i need a copy constructor in this case since 2 counters will be running in the program????
Here is the main.cpp file http://www.cs.uh.edu/~svenkat/lib/as...N1/assign1.cpp .
.h file
the .cpp file for the .hCode:class ModuloCounter { public: ModuloCounter(int ); ~ModuloCounter(); void increment (void); void decrement (void); int getNumberofModuloCounters(void)const; int getCounterLimit(int)const; int getCounterValue(void)const; private: int modLim; int currVal; int modCount; };
Code:#include "ModuloCounter.h" ModuloCounter::ModuloCounter(int set) { if(modCount==1)modCount++; modLim=set; } ModuloCounter::~ModuloCounter() { modCount--; } void ModuloCounter::increment(void) { if(currVal==modLim)currVal=1; else currVal++; } void ModuloCounter::decrement(void) { if(currVal==1)currVal=modLim; else currVall--; } int getNumberofModuloCounters(void)const { return modCount; } int getCounterLimit(int)const { return modLim; } int getCounterValue(void)const { return currVall; }