Sign in to follow this  

Sharing Enums Between Classes

This topic is 3314 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm experiencing a serious mental block and I can't figure out how to share an enum between several classes. From what I've read it can be achieved by using namespace but I've tried this and failed. My basic file structure looks like this...
player.h    location.h     EndLocation.h
   |             |                |
   |_____________|________________|
                 |
                 |
               Game.h
                 |
                 |
              Stdafx.h
                 |
                 |
              Main.cpp  

I'm trying to share a enum called position between both player and location. I've tried creating a .h file and defining the namespace EnumShare however after trying to load the file in both player.h and location.h it spat out an error reporting re-definition, which seems rather obvious to me now. Is there a simple way to share an enum between two classes? Am I going about this completely the wrong way?

Share this post


Link to post
Share on other sites

This topic is 3314 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this