title: assign one class object to another class object in c++
body: <p>I want to assign one class object to another class object in c++.</p>
  
  <p><strong><em>Ex:</em></strong>
  There is one class Dog and another class Cat. Create one one instance of each (d1 &amp; c1). Don't want to use any STL. I want to use this statement in my code  </p>
  
  <blockquote>
    <p>d1 = c1;</p>
  </blockquote>
  
  <p><strong>Program</strong></p>
  
  <pre><code>class dog
  {
      char  dc;
      float df;
      int   di;   
  public:
      void setdata2(char c, float f, int i)
      {   dc = c; df = f; di = i; }
      void showdata2()
      {   cout  &lt;&lt;"char =" &lt;&lt; dc &lt;&lt;", float =" &lt;&lt; df &lt;&lt;", int =" &lt;&lt; di  &lt;&lt;endl;   }
  };
  
  
  class cat
  {
      float cf;
      int ci;
      char cc;    
  public:
      void setdata(float f, int i, char c)
      {   cf = f; ci = i; cc = c; }
      void showdata()
      {   cout &lt;&lt;"float =" &lt;&lt; cf &lt;&lt;", int =" &lt;&lt; ci &lt;&lt;", char =" &lt;&lt; cc  &lt;&lt;endl;    }
  };
  
  
  int main()
  {
      dog d1, d2;
      cat c1, c2;
  
      d1.setdata2('A', 56.78, 30);
      c1.setdata(12.34, 2, 3);
      d1.showdata2();
      c1.showdata();
  
      d2 = c1;        // Question 1
  
      dog d3(c1);     // Question 2
  
      dog d4 = c1;    // Question 3
  
      return 0;
  }
  </code></pre>
  
  <p>Please answer <strong><em>Question 1/2/3</em></strong> each <strong><em>separately</em></strong>.</p>