I have a class, Square:
class Square
{
typedef enum {kTop = 0x80, kRight = 0x40, kBottom = 0x20, kLeft = 0x10} Side;
// Other functions and stuff
}
In one of my functions, I have a for loop that performs an operation involving each of the sides of a Square. I made it like this:
for (Square::Side side = Square::kLeft; side < Square::kLeft; side << 1) // Warning here
{
// Do stuff
}
First, the loop would work on the left side, and then it would shift the side one position to the left, making the side equal to the bottom side. After the for loop has performed its operations on the Top side, it would shift left again, pushing the bit off of the number and making it equal to 0, which is less than kLeft, and the loop would end.
However, it’s giving me a warning that says “for increment expression has no effect“. Does this mean that my shift operation is not happening?
Yes it does, because the stop condition is false on the first attempt:
renders
false.
Perhaps you meant
side <= Square::kTopor similar andside <<= 1.