adflixit
adflixit

Reputation: 39

How to define common enum in C++11?

So I've got some enum that is defined in one part and I need to use it in multiple other parts of program. As I suppose, there is no extern enums in C++11. So how to use the same defined enum in different units? Sorry for a duplicate or misunderstandings.

Upvotes: 0

Views: 94

Answers (1)

Sam Varshavchik
Sam Varshavchik

Reputation: 118302

This seems to be exactly what header files are for:

enum_def.H:

 enum class my_enum_type { /* .... */ };

file1.C:

 #include <enum_def.H>

file2.C:

 #include <enum_def.H>

Upvotes: 5

Related Questions