Does g++ support strongly typed enums?

I'm using g++ with -std=c++11 flag.

For some reason, I get an error whenever I use enum class.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>

using namespace std;


enum class State{PLAY, OPTION, EXIT};

int main(){
    State info = State::EXIT;
    
    cout << info << endl;

    return 0;
}



I'm assuming that g++ doesn't support strongly typed enums or did I do something wrong?
Read here - http://stackoverflow.com/questions/11421432/how-can-i-output-the-value-of-an-enum-class-in-c11

Hope that helps. Apparently you cant just print them out like that.
It does support them.
Line 11 is meaningless. You just defined new entity State, so compiler knows nothing about how to output it, as you did not provide such info.
Strongly typed enums should be supported unless your version of g++ is too old.

Line 11 of your code doesn't work because there is no overload of operator<< for the State type.
Topic archived. No new replies allowed.