title: Define a 'for' loop macro in C++
body: <p>Perhaps it is not good programming practice, but is it possible to define a <code>for</code> loop macro?</p>
  
  <p>For example,</p>
  
  <pre><code>#define loop(n) for(int ii = 0; ii &lt; n; ++ ii)
  </code></pre>
  
  <p>works perfectly well, but does not give you the ability to change the variable name <code>ii</code>.</p>
  
  <p>It can be used:</p>
  
  <pre><code>loop(5)
  {
      cout &lt;&lt; "hi" &lt;&lt; " " &lt;&lt; "the value of ii is:" &lt;&lt; " " &lt;&lt; ii &lt;&lt; endl;
  }
  </code></pre>
  
  <p>But there is no choice of the name/symbol <code>ii</code>.</p>
  
  <p>Is it possible to do something like this?</p>
  
  <pre><code>loop(symbol_name, n)
  </code></pre>
  
  <p>where the programmer inserts a symbol name into "<code>symbol_name</code>".</p>
  
  <p>Example usage:</p>
  
  <pre><code>loop(x, 10)
  {
      cout &lt;&lt; x &lt;&lt; endl;
  }
  </code></pre>