mardi 23 novembre 2021

Is there a benefit in assigning the last enum value in a list as -1?

I've seen it in coding conventions at previous/current job(s), but I can't seem to find a reason online for why this would be the preferred way of writing an enum:

enum class Mode
{
    Mode1,
    Mode2,
    Mode3,
    Mode4,
    Nil = -1
};

What (if any) is the benefit of adding the Nil = -1 line?

Aucun commentaire:

Enregistrer un commentaire