You are on page 1of 2

#include<iostream>

using namespace std;

class complex{

private:

int realnum, imagnum;

char ch='+';

char ch1='i';

public:

complex(){

realnum = 0;

imagnum = 0;

complex(int j){

realnum = j;

imagnum = j;

complex(int a, int b){

realnum = a;

imagnum = b;

friend void add(complex, complex);

friend void display();

};

void add(complex c1, complex c2){


complex c3;

c3.realnum = c1.realnum + c2.realnum;

c3.imagnum = c1.imagnum + c2.imagnum;

cout<<c3.realnum << c3.ch << c3.imagnum << c3.ch1;

void display(){

cout<<"The sum of two complex numbers is: ";

int main(){

complex c1(5,3);

complex c2(2,4);

add(c1,c2);

return 0;

You might also like