EXPERIMENT 4. oops lab

EXPERIMENT 4:Program to Understand Operator Overloading Concept in C++ EXP: write a program in c++  to Add to Complex no using operator overloading.   #include<iostream> #include<string.h> using namespace std; class complex {     int real,img; public: input() { cout<<“\nEnter Real part:-“; cin>>real; cout<<“Enter imaginary part:-“; cin>>img; } display() {cout<<endl<<real<<“+”<<img<<“i”; } complex operator-(complex t) { complex temp; temp.real=real+t.real; temp.img=img+t.img; return temp; } };   int main() { […]

Continue reading