title: Initialization lists,local variables vs data members
body: <pre><code>#include &lt;iostream&gt;
  using namespace std;
  class Ex {
  private:
      int i;
      float f;
  public:
      Ex(int i,float f):i(i),f(f) {
          cout &lt;&lt; this-&gt;i &lt;&lt; '\t' &lt;&lt; this-&gt;f &lt;&lt; endl;
      }
      ~Ex(){
          cout &lt;&lt; "destructor";
      }
  };
  int main() {
      Ex i(10,20.1f);
  }
  </code></pre>
  
  <p>In the program above I wrote above,if the constructor was parameterized constructor like the following:</p>
  
  <pre><code>Ex(int i,float f){
          i=i;
          f=f;
          cout &lt;&lt; this-&gt;i &lt;&lt; '\t' &lt;&lt; this-&gt;f &lt;&lt; endl;
      }
  </code></pre>
  
  <p>here the data members of the object are initialized to junk because data members are hidden due to local variables of same name.
  But in the program above it works fine without explicit this.How?</p>