0

I have an enum months:

enum months{jan = 1, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec};

However, when I am trying to use these enum values in an array:

int months[12] = { jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec };

The problem I am having, is in the Error list I am getting:

'oct' is ambiguous
'dec' is ambiguous

My guess as to why this is happening is that it is something to do with the words oct and dec, because when I change the words it gets rid of the error.

Does anyone know a fix for this problem?

I'm also slightly curious as to the reason why this is happening.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
SithLizard
  • 57
  • 1
  • 7
  • 6
    See [Why is `using namespace std;` considered bad practice?](https://stackoverflow.com/q/1452721/1458097) – heap underrun Apr 24 '22 at 00:25
  • Heres what theyre likely conflicting with: https://en.cppreference.com/w/cpp/io/manip/hex – Borgleader Apr 24 '22 at 00:31
  • 1
    `oct` (octal) and `dec` (decimal) are part of the standard library used to modify the `basefield` of a stream. As the comment above suggests, it's best to avoid `using namespace std` for this reason among others. – bradcush Apr 24 '22 at 00:33
  • @heapunderrun I checked out the post, and proceeded to stop using namespace std, however, I am still getting the same errors. – SithLizard Apr 24 '22 at 00:34
  • Ahhhh so I was correct to assume it was a problem with the word itself. Thank you all for your help, I greatly appreciate it! – SithLizard Apr 24 '22 at 00:36
  • The enum is named `months` and the array is named `months`. A problem known as the [Too Many Daves](https://allpoetry.com/poem/11575842-Too-Many-Daves-by-Theodor-Seuss-Geisel) problem. – Eljay Apr 24 '22 at 00:49

0 Answers0