Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,124 questions

40,786 answers

573 users

How to use enum in array with C++

1 Answer

0 votes
#include <iostream>

using std::cout;
using std::endl;

int main()
{
	enum Days { Sun, Mon, Tue, Wed, Thu, Fri, Sat, WeekDays };
	int arr[WeekDays] = { 1, 2, 3, 4, 5, 6, 7 };

	cout << arr[Sun] << endl;
	cout << arr[Mon] << endl;
	cout << arr[Tue] << endl;
	cout << arr[Wed] << endl;
	cout << arr[Thu] << endl;
	cout << arr[Fri] << endl;
	cout << arr[Sat] << endl;

	return 0;
}

/*
run:

1
2
3
4
5
6
7

*/

 





answered May 22, 2018 by avibootz

Related questions

1 answer 93 views
93 views asked Mar 13, 2022 by avibootz
1 answer 82 views
82 views asked May 22, 2018 by avibootz
1 answer 101 views
101 views asked Mar 19, 2018 by avibootz
5 answers 136 views
136 views asked Dec 11, 2020 by avibootz
1 answer 77 views
77 views asked May 22, 2018 by avibootz
...