dimanche 1 avril 2018

Error using "enum" within a class

I get the following error message about my enum, and I can't figure out why. I have only 1 header file and only 1 source file where I implemented all the functions (and main). I declared the enum within class "Survivor", in "public". I didn't forget to include the header file in the source file. Please help me see what I've done wrong.

"error: 'e_status' does not name a type"

This is my header file:

class Survivor
{
public:
    enum e_status {SINGLE, MARRIED, RELATIONSHIP};

    char* get_name();
    int get_age();
    e_status get_status();

    void set_name(char n[]);
    void set_age (int a);
    void set_status (e_status s);

    const void print();

private:

    char name [20];
    int age;
    e_status status;
};

This is the relevant part in my Source file:

e_status Survivor::get_status()
{
    return status;
}

Aucun commentaire:

Enregistrer un commentaire