C/C++ programmers, please confirm
Posted: Sat Aug 04, 2018 10:53 pm
A question for those who know C/C++. Well, two questions. Please, correct everything that's wrong from the following, or confirm that my assumptions are correct!
1) enum is a list of specific integer values that are accessed by their name
Now, enum D_Mon is an integer with the value 0, D_Wen has the value 2, D_Sat the value 5
2) typedef is a way to rename existing types without changing their content or structure.
Now I can access "unsigned short" with USHORT.
3) if both is used at once, it just means that an enum is defined and at the same time given an alternative name?
The enum is now accessible as _FILEOPENDIALOGOPTIONS, and the content is following standard rules:
FOS_OVERWRITEPROMPT == 0
FOS_STRICTFILETYPES == 1
FOS_NOCHANGEDIR == 2
FOS_PICKFOLDERS == 3
etc.
Does it matter, if I call something with an enum named integer or directly use the integer (I think not)?
1) enum is a list of specific integer values that are accessed by their name
- Code: Select all
enum {
D_Mon ,
D_Tue ,
D_Wen ,
D_Thu ,
D_Fri ,
D_Sat ,
D_Sun ,
};
Now, enum D_Mon is an integer with the value 0, D_Wen has the value 2, D_Sat the value 5
2) typedef is a way to rename existing types without changing their content or structure.
- Code: Select all
typedef unsigned short USHORT;
Now I can access "unsigned short" with USHORT.
3) if both is used at once, it just means that an enum is defined and at the same time given an alternative name?
- Code: Select all
typedef enum _FILEOPENDIALOGOPTIONS {
FOS_OVERWRITEPROMPT ,
FOS_STRICTFILETYPES ,
FOS_NOCHANGEDIR ,
FOS_PICKFOLDERS ,
FOS_FORCEFILESYSTEM ,
FOS_ALLNONSTORAGEITEMS ,
FOS_NOVALIDATE ,
FOS_ALLOWMULTISELECT ,
FOS_PATHMUSTEXIST ,
FOS_FILEMUSTEXIST ,
FOS_CREATEPROMPT ,
FOS_SHAREAWARE ,
FOS_NOREADONLYRETURN ,
FOS_NOTESTFILECREATE ,
FOS_HIDEMRUPLACES ,
FOS_HIDEPINNEDPLACES ,
FOS_NODEREFERENCELINKS ,
FOS_OKBUTTONNEEDSINTERACTION ,
FOS_DONTADDTORECENT ,
FOS_FORCESHOWHIDDEN ,
FOS_DEFAULTNOMINIMODE ,
FOS_FORCEPREVIEWPANEON ,
FOS_SUPPORTSTREAMABLEITEMS
} ;
The enum is now accessible as _FILEOPENDIALOGOPTIONS, and the content is following standard rules:
FOS_OVERWRITEPROMPT == 0
FOS_STRICTFILETYPES == 1
FOS_NOCHANGEDIR == 2
FOS_PICKFOLDERS == 3
etc.
Does it matter, if I call something with an enum named integer or directly use the integer (I think not)?