Assigning name to the integer value using enum data type for file open flags C++ example


Compiler: Visual C++ Express Edition 2005

Compiled on Platform: Windows 2003 Server Standard Edition

Header file: Standard

Additional project setting: Set project to be compiled as C++

Project -> your_project_name Properties -> Configuration Properties -> C/C++ -> Advanced -> Compiled As: Compiled as C++ Code (/TP)

Other info: none

To do: Assigning name to the integer value using enum for the Win32 file open flags

To show: Another enum C++ code example, enumerating the file open flags




#include <iostream>

using namespace std;


// enum definition

enum FileOpenFlags


// defined here...

OpenReadOnly = 1,

// using OpenReadOnly as the next initializer and so on...

OpenReadWrite = OpenReadOnly,

OpenBinary = OpenReadWrite,

OpenText = OpenBinary,

OpenShareable = OpenText



int main(void)


// Used a lot in Win32 programming...

cout<<"Test the OpenReadOnly value = "<<OpenReadOnly<<endl;

cout<<"Test the OpenReadWrite value = "<<OpenReadWrite<<endl;

cout<<"Test the OpenBinary value = "<<OpenBinary<<endl;

cout<<"Test the OpenText value = "<<OpenText<<endl;

cout<<"Test the OpenShareable value = "<<OpenShareable<<endl;

return 0;



Output example:


Test the OpenReadOnly value = 1

Test the OpenReadWrite value = 1

Test the OpenBinary value = 1

Test the OpenText value = 1

Test the OpenShareable value = 1

Press any key to continue . . .



C and C++ Programming Resources | C & C++ Code Example Index