954,168 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

C++ Beginner - Enumerations

Can somebody please tell me where I should put an enumeration which will be used by several classes.

enum Direction
{
             UP = 1,
	DOWN = 2,
	NONE = 3
};


All of the classes have their own .h and .cpp files and at the moment I have the enumeration repeated in all the header files for the classes which use it.

I assume repeating the enum in multiple files is the wrong way to do it. Is there a right way to do it?

Thanks,
James


<< moderator edit: added code tags : [code][/code] tags >>

j.kelly
Newbie Poster
10 posts since Mar 2005
Reputation Points: 11
Solved Threads: 0
 

Why not put that in its own header and #include it where you need it?

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

Ok, will do.

Thanks

j.kelly
Newbie Poster
10 posts since Mar 2005
Reputation Points: 11
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You