title: Why address-of operator ('&') can be used with objects that are declared with the register storage class specifier in C++?
body: <p>In C programming language we are not allowed to use address-of operator(&amp;) with variables which are declared with register storage class specifier.</p>
  
  <p>It gives <code>error: address of register variable ‘var_name’ requested</code></p>
  
  <p>But if we make a c++ program and perform the same task (i.e use the <code>&amp;</code> with register storage variable) it doesn't gives us any error.</p>
  
  <p>eg.</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  int main()
  {
      register int a;
      int * ptr;
      a = 5;
      ptr = &amp;a;
      cout &lt;&lt; ptr &lt;&lt; endl;
      return 0;
  }
  </code></pre>
  
  <p>Output :-</p>
  
  <pre><code>0x7ffcfed93624
  </code></pre>
  
  <p>Well this must be an extra feature of C++, but the question is on the difference between register class storage in C and C++.</p>