Search code examples
c++enumsprogram-entry-point

Should I place my enum out or inside of my int main()?


My code works, altough I have a feeling that it could be improved, especially my enum which is currently inside the main() function.

I've tried placing my enum outside of the int main function, it still works, I personally think it wouldn't be very presentable.

bookPicker.cpp

int main()
{

enum element {
    ICE, FIRE, EARTH, WIND, NONE
};

..The rest of the code..

   return 0;

}

Any tips would be much appreciated.

reference to C++ How to translate my code to OOP with classes and functions?


Solution

  • Outside. You will want to use this enum for a class, the class may be defined someplace else, requiring the enum. So it should be outside.

    Also, maybe better to use an enum class in modern C++.