Anonymous enums

Anonymous enums are the enum in C/C++ that we can access its elements without declaring an enum variable

#include <iostream>
using namespace std;
int main()
{
    enum weekday{mon,tue,wed, thus,fri,sat,sun};
    cout << "day=" <<sat<< endl;//with out using declaration enum weekday; we can access its elements
    return 0;
}

Output

day=5

Mohammed Anees

Hey there, welcome to aneescraftsmanship I am Mohammed Anees an independent developer/blogger. I like to share and discuss the craft with others plus the things which I have learned because I believe that through discussion and sharing a new world opens up

Leave a Reply

Your email address will not be published.