C++ – Where to put the enum in a cpp program

c++

I have a program that uses enum types.

enum Type{a,b,};


class A
{
 //use Type
};
class B
{
  // also use that Type
};

2 class are located in 2 different files.
Should I put the type definition in a headfile or
in class definition for each class?

Best Solution

If the enum is going to be used in more than one .cpp file, you should put it in a header file that will be included by each. If there's a common header file, you should use that, otherwise you may as well create a new header file for this enum