Faisal Arshad
Faisal Arshad

Reputation: 11

problem using enum in another cpp file

Hi I a have created a global.h file in which I define enum Token I get the garbage value of token if I use the value of Token other than glabal.cpp file I have also include the "global.h" file in other file where I am using the Token value how can I correct this problem.

Upvotes: 1

Views: 625

Answers (1)

Brian R. Bondy
Brian R. Bondy

Reputation: 347216

If I am correct in assuming that your problem is that you don't want to include global.h in each of your files...

You need to include the enum in any source file you use it from. You cannot forward declare an enum.

Upvotes: 1

Related Questions