Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

C++ exercise 3. Complex Numbers. Implement a C++ class Complex to store complex numbers. A complex number is a number that is formed of a

C++ exercise image text in transcribed
image text in transcribed
3. Complex Numbers. Implement a C++ class "Complex" to store complex numbers. A complex number is a number that is formed of a real and of an imaginary part. It can be expressed as: a + bi where a is the real number, and b is the imaginary unit. For example: 2 3i. More precisely, your class should contain: 1. Data members: double real double imaginary. 2. A constructor that takes the real and imaginary parts. 3. A default constructor that initializes both data items to 0 Then you need to implement the following: 1. Overload the output operator () to take a complex number as input as follows: real + imaginary i (or real - imaginary i). 3. Overload the corresponding operator, to allow the addition of two complex numbers. To add two complex numbers, the real numbers will be added together and the imaginary ones will be added together. For example: C1 12 34i C2 10+40i C3 C1 C2 226i 6. In the main function: (a) Take two complex numbers as input from the user. (b) Display the two numbers C1 and C2 (using cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions