Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

There are two questions in total. Please answer question 2. Thank you. The code for Question 1 is below: #include using namespace std; class Complex

There are two questions in total. Please answer question 2. Thank you.

image text in transcribedimage text in transcribed

The code for Question 1 is below:

#include using namespace std; class Complex { double real,imag; public: Complex(){} //default constructor Complex(double r,double i):real(r),imag(i){} //parametrized constructor friend istream& operator>>(istream& i,Complex& c); //overloaded input friend function friend ostream& operator>(istream& i,Complex& c) { //we use istream& for return part to implement cascading cout>c.real; //User entering real part cout>c.imag; //User entering imaginary part return i; //returning istream object } ostream& operator>c1>>c2; //user entering 2 2 numbers cout

Thank you

1) Complex Number Class Extend the Complex class that you completed in last week's Lab Exercises. Recall that a complex number is of the form a + bi where a and b are real numbers and i2-1. For example, 2.45.2i and 5.73 - 6.9i are complex numbers. a is referred to as the real part of the complex number and bi the imaginary part. Make the following changes to the Complex class definition: a) Add a constructor that will take two double arguments and initialize the real and imaginary components respectively. b) Replace the input and output methods with overloaded>> and

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

13-4 What are alternative methods for building information systems?

Answered: 1 week ago

Question

13-1 How does building new systems produce organizational change?

Answered: 1 week ago