Passing a enum value to a function

Hey guys, I'm just curious how would I code a function header and parameters to except a enum value I created.

 
 enum fields{word, hint, num_fields};
1
2
3
4
5
6
7
8
9
10
11
12
13
enum fields{word, hint, num_fields};

void do_stuff(fields field)
{
    switch(field) {
        case word: std::cout << "WORD\n"; break;
        case hint: std::cout << "HINT\n"; break;
        default: std::cerr << "Unexpected value\n"; std::exit(EXIT_FAILURE);
    }
}

//...
do_stuff(hint);


Last edited on
ok thanks man
Last edited on
Topic archived. No new replies allowed.