Enum

how to return a value from a function as enum?

typedef enum { MALE, FEMALE } Gender;
for this example, if i want to return MALE as a return value to the function?
1
2
3
4
5
6
7
8
9
10
11
enum class Gender
{
    Male,
    Female,
    Other
};

Gender getGender()
{
    return Gender::Male;
}
is there another way to solve this problem, or i just have to make it as a class ?
thank you
enum class is a single keyword that just happens to contain a space. It is the same as enum except that the enumerated names are inside the scope of the enum. If you just write enum, then the enumerated names are in the enclosing scope (this is generally undesirable).
Topic archived. No new replies allowed.