diff --git a/C++/program_30/operator_overloading.cpp b/C++/program_30/operator_overloading.cpp new file mode 100644 index 0000000..8426dd4 --- /dev/null +++ b/C++/program_30/operator_overloading.cpp @@ -0,0 +1,50 @@ + +/* +cpp program for operator overloading +Author: Anil Kumar +Date modified:21-10-2021 +*/ + + +#include +using namespace std; + +class complex +{ +private: + float a,b; +public: + + void set(float x, float y){ + a=x; + b=y; + } + complex operator+(complex c){ + complex t; + t.a=a+c.a; + t.b=b+c.b; + return t; + } + complex operator-(){ + complex t; + t.a=-a; + t.b=-b; + return t; + } + + void display(){ + cout<