943,982 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1544
  • C++ RSS
Mar 19th, 2005
0

C++ Beginner - Enumerations

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

C++ Syntax (Toggle Plain Text)
  1. enum Direction
  2. {
  3. UP = 1,
  4. DOWN = 2,
  5. NONE = 3
  6. };

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 >>
Similar Threads
Reputation Points: 11
Solved Threads: 0
Newbie Poster
j.kelly is offline Offline
10 posts
since Mar 2005
Mar 19th, 2005
0

Re: C++ Beginner - Enumerations

Why not put that in its own header and #include it where you need it?
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Mar 19th, 2005
0

Re: C++ Beginner - Enumerations

Ok, will do.

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

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: creating a window based dialog
Next Thread in C++ Forum Timeline: Need a little hint





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC