| | |
C++ Beginner - Enumerations
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2005
Posts: 10
Reputation:
Solved Threads: 0
Can somebody please tell me where I should put an enumeration which will be used by several classes.
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 >>
C++ Syntax (Toggle Plain Text)
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 >>
Why not put that in its own header and #include it where you need it?
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
![]() |
Similar Threads
- MS Access Beginner (MS SQL)
- PHP Beginner Here (PHP)
- beginner (C++)
- Beginner's questions: C++ and databases (C++)
- beginner needs help with game programming (Game Development)
Other Threads in the C++ Forum
- Previous Thread: C++ Beginner - #include recursion problem
- Next Thread: Need a little hint
Views: 1396 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for C++
6 add api array arrays beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete desktop directshow dll encryption error file forms fstream function functions game getline givemetehcodez google graph homeworkhelper iamthwee ifstream input int integer java lazy lib linkedlist linux loop looping loops map math matrix memory microsoft newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort string strings struct studio system template templates test text tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






