user692601
user692601

Reputation: 107

enums declaration in class C++, problem getting to enum in class

I have problem with the declaration of enum in my class. I had tried to declare it on private, public, outside, in the main, nothing works. I need to call function in the class from outside and use the enums in the function here is my code.

class Algoritem {
    public:
    enum Optimization { W , A , D };
    enum FenceType { OF , CC };
    enum Eventopa { BR , OR };
    algorithem* OptimalPatrol(double N, int K, double VS, double T, Optimization F,FenceType FT, Eventopa E, double Imax,double P);
};

When I need to call OptimalPatrol() I need to input the 3 enums. I can't redeclare them in the main, so how can I input my enums with variable from the main?

Upvotes: 1

Views: 525

Answers (1)

AVH
AVH

Reputation: 11516

You have to specifiy which class the enums are defined in. So, e.g. call the function like this:

OptimalPatrol(N, K, VS, T, Algoritem::W, Algoritem::OF, Algoritem::BR, Imax, P);

That way, your compiler knows in which class to look for the enum declarations.

Upvotes: 8

Related Questions