title: How to initialize the reference member variable of a class?
body: <p>Consider the following code C++:    </p>
  
  <pre><code>    #include&lt;iostream&gt;
  
  using namespace std;
  
  class Test {
      int &amp;t;
  public:
      Test (int &amp;x) { t = x; }
      int getT() { return t; }
  };
  
  int main()
  {
      int x = 20;
      Test t1(x);
      cout &lt;&lt; t1.getT() &lt;&lt; " ";
      x = 30;
      cout &lt;&lt; t1.getT() &lt;&lt; endl;
      return 0;
  }
  </code></pre>
  
  <p>It is showing the following error while using gcc compiler</p>
  
  <pre><code>    est.cpp: In constructor ‘Test::Test(int&amp;)’:
      est.cpp:8:5: error: uninitialized reference member ‘Test::t’ [-fpermissive]
  </code></pre>
  
  <p>Why doesn't the compiler directly call the Constructor?</p>