Preview:
#include <bits/stdc++.h>
using namespace std;

class Complex
{
   public:
    int real;
    int img;
   
   Complex(int r=0,int i=0)
   {
      real=r;
      img=i;
   }
   Complex operator+(Complex c)  //operator overloading or
    {                            //(Complex add(Complex c)
      Complex temp;
      temp.real=real+c.real;
      temp.img=img+c.img;
      return temp;
    }
};
int main()
{
   Complex c1(2,5),c2(3,5),c3;
   
   c3=c1+c2;                     // or c3=c1.add(c2);
   cout<<c3.real<<"+i"<<c3.img<<endl;
	return 0;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter