title: C++ volatile member functions
body: <pre><code>class MyClass
  {
      int x, y;
      void foo() volatile {
          // do stuff with x
          // do stuff with y
      }   
  };
  </code></pre>
  
  <p>Do I need to declare <code>x</code> and <code>y</code> as <code>volatile</code> or will be all member variables treated as <code>volatile</code> automatically?</p>
  
  <p>I want to make sure that "stuff with <code>x</code>" is not reordered with "stuff with <code>y</code>" by the compiler.</p>
  
  <p>EDIT:
  What happens if I'm casting a normal type to a <code>volatile</code> type? Would this instruct the compiler to not reorder access to that location? I want to pass a normal variable in a special situation to a function which parameter is volatile. I must be sure compiler doesn't reorder that call with prior or followed reads and writes.</p>