#include #include using namespace std; // unscoped enumeration // zero = 0, un = 1, ... enum { zero, un, deux, trois }; // unscoped enumeration // mardi = 2, .... enum Jour { lundi=1, mardi, mercredi, jeudi, vendredi, samedi, dimanche }; // Scoped enumeration enum class Mois { Janvier = 1, Fevrier, Mars, Avril, Mai, Juin, Juillet, Aout, Septembre, Octobre, Novembre, Decembre }; int main() { // un_jour = 2, no scope Jour un_jour = mardi; // can convert easily to integer if unscoped int m = un_jour; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // because unscoped enum 'mardi' does not reference // the constant of Jour int mardi = -123; // you have to write this: mardi = Jour::mardi; cout << "un_jour = " << un_jour << endl; cout << "mardi = " << mardi << endl; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // still possible to write this ! int Janvier = -56; // need to cast a scoped constant cout << "Fevrier = " << static_cast(Mois::Fevrier) << endl; return EXIT_SUCCESS; }