title: Operator overloading using constructor add two Complex number
body: <p>I wanted to get a value from the user via using constructor and another value will be in the program itself. I try to code it as below. But constructor is initializing all the values to 0,0(no argument). What to do?</p>
  
  <pre><code>#include&lt;iostream&gt;
  
  using namespace std;
  
  class complex
  {
        float x;
        float y;
        public : 
               complex() //no argument constructor
               {
                      /* cout&lt;&lt;"Enter real = ";
                        cin&gt;&gt;x;
                        cout&lt;&lt;"Enter imaginary = ";
                        cin&gt;&gt;y;*/
               }
               complex(float real, float imag)
               {
  
                        cout&lt;&lt;"Enter real = ";
                        cin&gt;&gt;x;
                        cout&lt;&lt;"Enter imaginary = ";
                        cin&gt;&gt;y;
                             x = real;
                             y = imag;
               }
               complex operator+(complex);
               void display(void);
  };
  
  complex complex :: operator+(complex c)
  {
          complex temp;
          temp.x = x + c.x;
          temp.y = y+c.y;
          return(temp);
  }
  void complex :: display(void)
  {
       cout&lt;&lt;x&lt;&lt;" +i"&lt;&lt;y&lt;&lt;"\n";
  }
  int main()
  {
      complex c1,c2(2.5,1.7),c3(0,0);
      c3 = c1+c2;
      c1.display();
      c2.display();
      c3.display();
      system ("PAUSE");
     // return 0;
  }
  </code></pre>