Board index » cppbuilder » Handling of Enum variables...

Handling of Enum variables...


2005-06-13 03:10:49 PM
cppbuilder95
Hi all,
usually the cpp files are used for data declarations and hpp
files are using for references to these data or for definitions
of classes, structures and so on.
But what is with enum variables?
Have I to make the definitions also in the header files?
I assume this as extern is not allowed for enum variables
so it would make sence to handle it like classes. Right?
Merci Marius
 
 

Re:Handling of Enum variables...

"mauro" < XXXX@XXXXX.COM >wrote:
Quote
Hi all,
Allo
Quote
usually the cpp files are used for data declarations and hpp
files are using for references to these data or for definitions
of classes, structures and so on.
Header files (h, hpp) are usually for declarations. A declaration is
something that may be seen multiple times without error, because it
tells the compiler about something that exists (is defined) elsewhere.
Also, header files are for declarations that will be used in multiple
source files.
Quote
But what is with enum variables?
enum's are effectively type declarations. An enum _variable_ is another
matter.
Quote
Have I to make the definitions also in the header files?
I assume this as extern is not allowed for enum variables
so it would make sence to handle it like classes. Right?
In the following, HomeTongue is an enum variable:
enum Language { French, English, German } ;
Language HomeTongue;
In the above, Language is a type - and is declared here - and HomeTongue
is a variable.
Being a variable, it may be made extern:
enum Language { French, English, German } ;
extern Language HomeTongue;
Alan Bellingham
--
ACCU Conference 2006 - 19-22 April, Randolph Hotel, Oxford, UK