title: How does copy constructor execute?
body: <p>I'm trying to understand copy constructor in detail. While doing so, i made the following example,</p>
  
  <pre><code>#include&lt;iostream&gt;
  
  class Test
  {
  private:
          int a;
  public:
          /*
          Test(const Test &amp;t)                          // User defined copy constructor
          {
              a = t.a;
          } */
          Test()
          {
                  a = 120;
          }
          int display()
          {
                  return a ;
          }
          void set(int var)
          {
                  a = var;
          }
  };
  
  int main()
  {
          Test t1;
          std::cout &lt;&lt; "t1.a " &lt;&lt; t1.display() &lt;&lt; std::endl;
          Test t2 = t1;                                           //Default copy constructor is called
          std::cout &lt;&lt; "T2.a " &lt;&lt; t2.display() &lt;&lt; std::endl;
          t2.set(99);                                             //Changing the value
          std::cout &lt;&lt; "t1.a " &lt;&lt; t1.display() &lt;&lt; std::endl;
          std::cout &lt;&lt; "T2.a " &lt;&lt; t2.display() &lt;&lt; std::endl;
          return 0;
  }
  </code></pre>
  
  <p>I read online that default copy constructor does "shallow copy" So it means if obj1 = obj2, what ever change i do in obj1 or obj2 even after the assignment
  needs to be reflected on both the object as they point to same location.
  But in this example when i change the value in one object it is not getting reflected in the other. Same result is obtained when using user defined copy constructor.</p>
  
  <p>Can some one clarify this topic, whether shallow copy is happening or not!</p>
  
  <p>Thanks!</p>