Enumeration Trouble

I'm sorry for asking so much but I'm having trouble with an assignment :P

This program is supposed to take color inputs and check how many times 2 colors repeat after each other, but it's not working:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
using namespace std;

void main()
{
	enum color {red, green, blue, yellow};
	color A[99999];

	int count = 0;
	int N=0;

	cout<<"Please enter the number of inputs: ";
	cin>>N;
	cout<<"Please enter the colors:\n";

	for (int i=0; i<N; i++)
		cin>>A[i];

	for (int j=0; j<N; j++)
		if (A[j] == A[j+1])
			count++;

	cout<<"There are " <<count <<" times where 2 consecutive colors are the same. ";
}


The compiler is not accepting the type 'color'...
closed account (zb0S216C)
Try reading this: http://www.cppreference.com/wiki/keywords/enum

Tip: Enumerated values are constant.

Edited.
Last edited on
Thanks for the website, framework :)
But my problem is that i want to input the constants of the type 'color' itself, in an array, and I cannot do that...does someone know how to do that...but in simple terms (because it's just my second course in C++ xD)?
closed account (zb0S216C)
As the tip I gave you specifies, enumerated variables are constant. Therefore, enumerated values cannot be changed. The instance of color is pointless. Look at it this way: You have 99999 instances of color. The values of each element of the array cannot change their values because they are constant. In turn, all the values of each element remain the same.

Note this: If you do not assign a value to an enumerated variable, the compiler will assign a default one for you - leaving the variable initialized.

Edited.
Last edited on
Topic archived. No new replies allowed.