25complex CPP
25complex CPP
BATCH-B
ROLL NO-25
[CODE]
#include <iostream>
using namespace std;
class Complex {
private:
int real, imag;
public:
//constructor
Complex(int r = 0, int i = 0) {real = r; imag = i;}
//friend functions of complex class
friend ostream & operator << (ostream &out, Complex const
&obj);
friend istream & operator >> (istream &in, Complex &obj);
//overloading of + operator
Complex operator + (Complex const &obj)
{
Complex res;
res.real = real + obj.real;