Skip to main content

Posts

Featured

SE Computer SPPU Object Oriented Programming (OOP) all codes and output (2019 pattern)

  Created By – Learning Bandhu Youtube Q1 . Implement a class complex which represents the complex number datatypes.Implement the following operations: 1.Constructor(including a default constructor which creates the complex number 0+0i); 2.Overload operator + to add two complex numbers. 3.Overload operator * to multiply two complex numbers. 4. Overload operator << and >> to print and read complex numbers. Code : #include<iostream> using namespace std; class Complex {  public : float real,img; Complex() {} Complex operator +(Complex); Complex operator *(Complex); friend ostream & operator <<(ostream&,Complex&); friend istream & operator >>(istream&,Complex&); }; Complex Complex::operator +(Complex obj) { Complex temp; temp.real=real+obj.real; temp.img=img+obj.img; return temp; } Complex Complex::operator *(Complex obj) { Complex temp; temp.real=real*obj.real-img*obj.img; temp.img=real*...

Latest Posts