Hi there, I've taken 2 OOP C# classes, but now our professor is switching over to c++. So, to get used to c++, I wrote this very simple program, but I keep getting this error:
error C2533: 'Counter::{ctor}' : constructors not allowed a return type
I'm confused, because I believe I have coded my default constructor right.
Here's my code for the simple counter class:
class Counter
{
private:
int count;
bool isCounted;
public:
Counter();
bool IsCountable();
void IncrementCount();
void DecrementCount();
int GetCount();
}
Counter::Counter()
{
count = 0;
isCounted = false;
}
bool Counter::IsCountable()
{
if (count == 0)
return false;
else
return true;
}
void Counter::IncrementCount()
{
count++;
isCounted = true;
}
void Counter::DecrementCount()
{
count--;
isCounted = true;
}
int Counter::GetCount()
{
return count;
}
What am I doing wrong? I'm not specifying a return type. Or am I somehow?