Using keyword 'enum' in C++ programming

//enum is an alternative way for creating symbolic constant.
#include<iostream>
using namespace std;
enum color{red,blue,green,yellow};
int main()
{
    int a,b,c,d;
    a=red;
    b=blue;
    c=green;
    d=yellow;
    cout<<a<<endl<<b<<endl<<c<<endl<<d;
    return 0;
}
output
here we get alternative value 0 for red and 1 for blue and so on.











Other C++ Programming:


No comments

Powered by Blogger.