title: How do you use bitwise flags in C++?
body: <p>As per <a href="http://www.mazeworks.com/mazegen/mazetut/index.htm" rel="nofollow noreferrer">this</a> website, I wish to represent a Maze with a 2 dimensional array of 16 bit integers.</p>
  
  <p>Each 16 bit integer needs to hold the following information:</p>
  
  <blockquote>
    <p>Here's one way to do it (this is by no means the only way): a 12x16 maze grid can be represented as an array m[16][12] of 16-bit integers. Each array element would contains all the information for a single corresponding cell in the grid, with the integer bits mapped like this: </p>
    
    <p><a href="https://i.stack.imgur.com/QmTW6.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QmTW6.gif" alt="alt text"></a><br>
    <sub>(source: <a href="http://www.mazeworks.com/mazegen/mazetut/tut5.gif" rel="nofollow noreferrer">mazeworks.com</a>)</sub>  </p>
    
    <p>To knock down a wall, set a border, or create a particular path, all we need to do is flip bits in one or two array elements. </p>
  </blockquote>
  
  <p>How do I use bitwise flags on 16 bit integers so I can set each one of those bits and check if they are set.</p>
  
  <p>I'd like to do it in an easily readable way (ie, Border.W, Border.E, Walls.N, etc).  </p>
  
  <p>How is this generally done in C++?  Do I use hexidecimal to represent each one (ie, Walls.N = 0x02, Walls.E = 0x04, etc)?  Should I use an enum?</p>
  
  <hr>
  
  <p>See also <a href="https://stackoverflow.com/questions/47981/how-do-you-set-clear-and-toggle-a-single-bit-in-c">How do you set, clear, and toggle a single bit?</a>.</p>