1 Attachment(s)
[RESOLVED] Burnt out. Not sure what I'm doing wrong
Code:
Counter
{
int counter;
int counterID;
int nCounters;
Counter(int preset);
void increment();
void decrement();
int getValue();
int getCounterID();
};
int Counter::nCounters = 0;
Counter::Counter(int value)
{
counter = value;
nCounters = nCounters + 1;
counterID = nCounters;
}
void Counter::increment()
{
counter++;
}
void Counter::decrement()
{
counter--;
}
int Counter::getValue()
{
return counter;
}
int Counter::getCounterID()
{
return counterID;
}
Attachment 35449
Re: Burnt out. Not sure what I'm doing wrong
It looks like you forgot to say 'struct' or 'class'.
If you choose 'class', then you need to make your member functions public.
Re: Burnt out. Not sure what I'm doing wrong
Code:
int Counter::nCounters = 0;
... and ncounters static!
Re: Burnt out. Not sure what I'm doing wrong
Thank you! I figured it out!
Code:
int Counter::nCounters = 0;
Counter::Counter(int i)
{
counter = i;
nCounters++;
counterID = nCounters;
}
void Counter::increment()
{
counter++;
}
int Counter::getValue()
{
return counter;
}
void Counter::decrement()
{
counter--;
}
int Counter::getCounterID()
{
return counterID;
}