What's the result?

Hi! guys
I am here with a problem a want a result of a line. I want to check if its result is in numbers or in alphabets

enum COLOR{ RED,BLUE,GREEN,WHITE,BLACK}
closed account (zb0S216C)
rckinesis wrote:
"I want to check if its result is in numbers or in alphabets"

An enumeration won't help you here, Sonny-Jim. An enumeration is simply a list of constants. Though, what you're asking is quite vague.

Wazzak
If I have understood correctly the result of the line ( if you would place a semicolon at the end of the statement) is enumeration type COLOR.
By default a enum has a type of int, so in your case a simple example
1
2
3
4
5
6
7
8
9
10
#include<iostream>
using namespace std;


enum COLOR{ RED,BLUE,GREEN,WHITE,BLACK};

int main() {

	cout<< RED<<" "<<BLUE<<" " << GREEN <<" "<< WHITE <<" "<<BLACK<<endl;
}


output should be :
 
0 1 2 3 4
Last edited on
@therockon7throw
By default a enum has a type of int, so in your case a simple example


It is invalid statement. Each enumeration has its own type.:)
closed account (zb0S216C)
therockon7throw wrote:
"By default a enum has a type of int"

The underlying type of an enumeration is implementation-defined; it can be a: signed int, unsigned int, bool, or char. The value of an enumerator must not be larger than int unless it exceeds the range of an signed int and unsigned int.

Wazzak
Maybe he was thinking about scoped enumerations (enum class) which has int as underlying type by default.
Last edited on
Topic archived. No new replies allowed.