c++ Function to return an enum?
c++, enums, function
Solution
Just return the enum by value:
class Paddle : public Entity
{
// as before...
paddleNS::COLOUR currentColour() const { return colour; }
};
Problem
So I have this namespace called paddleNS for the class called paddle, inside paddleNS I have an enum known as colour ``` namespace paddleNS { enum COLOUR {WHITE = 0, RED = 1, PURPLE = 2, BLUE = 3, GREEN = 4, YELLOW = 5, ORANGE = 6}; } class Paddle : public Entity { private: paddleNS::COLOUR colour; public: void NextColour(); void PreviousColour(); void PaddleColour(paddleNS::COLOUR col) { colour = col; } }; ``` Now then, what I was wondering is how would I go about creating a function that will return what the colour currently is also is there an easier way to return it in text form instead of a value or am I better of just using a switch to figure out what the colour is?