mercredi 2 juin 2021

Integer overflow in enums, loop through only named integers

How can I achieve this behavior?

enum week {
    sunday=0, monday, tuesday, wednesday, thursday, friday, saturday
};
enum week day = saturday; // 6
// ++day => 0
enum week day = sunday; // 0
// --day => 6

Aucun commentaire:

Enregistrer un commentaire