Where do I declare an enum type so that every class header file has access to it?
In its own header. Make a separate header file for your enum
, and #include
that header in all other headers that need to use it. Don't forget to add include guards to avoid multiple inclusions:
#ifndef MOVE_H
#define MOVE_H
enum move foo {
LEFT, RIGHT, UP, DOWN
};
#endif /* MOVE_H */
Note: If you have multiple enumerations that logically belong together, or an enum
that belongs together with a class, you may want to put the two in the same header.