title: How an alias for a variable works in C++
body: <p>As per my knowledge for <code>int a;</code> compiler will allocate a memory segment in stack, for <code>int *p;</code> also compiler will allocate a memory segment in stack but here <code>p</code> can only point to an address of <code>integer</code> variable.</p>
  
  <p>In C++ we have a concept called <code>alias</code> (aka 'reference') like <code>int &amp;x=a;</code> that means <code>x</code> will start working like <code>a</code>.</p>
  
  <p>My question is whether the compiler allocates any separate memory segment for <code>x</code> also or compiler will treat <code>x</code> as <code>a</code> only; I mean will the compiler assign same address for both. </p>