So, I am writing a game using C ++ and in my training state, I have different steps that the user views, explaining how the game works. I want to increase the step at which the user is logged in after a specific action. (Mouse click). I tried to reload the statement ++
, but I got an error message binary '++': 'STEPS' does not define this operator or a conversion to a type acceptable to the predefined operator
. I am using visual studio and error code C2676
.
I have an enum class configured as follows:
enum class STEPS
{
ONE,
TWO,
END_OF_LIST
};
STEPS& operator++(STEPS& s)
{
s = staic_cast<STEPS>(static_cast<int>(s) + 1);
if (s == STEPS::END_OF_LIST)
{
s = static_cast<STEPS>(static_cast<int>(s) - 1);
}
return s;
}
In my update function of my textbook status class, I check if the mouse has been clicked. If it's me, I'm trying to increase the steps.
// this is defined in the header and STEPS :: ONE is set for initialization
STEPS steps;
TutorialState::Update()
{
if (mouse.Left())
{
steps++;
}
}
Vince source
share