Define a class for complex numbers. A complex number is a number of the form a + bi, where a and b are double type data and I is a number that represents the quantity √-1. Class name is Complex. Name the private member variables real and imaginary. Default constructor that initializes an object to 0 (that is, 0 + 0i) Constructor with two parameters Other functions (See next slide)
Define a class for complex numbers. A complex number is a number of the form a + bi, where a and b are double type data and I is a number that represents the quantity √-1. Class name is Complex. Name the private member variables real and imaginary. Default constructor that initializes an object to 0 (that is, 0 + 0i) Constructor with two parameters Other functions (See next slide)
Chapter2: Using Data
Section: Chapter Questions
Problem 14RQ
Related questions
Question
Use C++

Transcribed Image Text:#include<iostream>
using namespace std;
class Complex
{
public:
};
Complex(); // set both real and imaginary to e
Complex (double, double);
Complex addition (const Complex&);
Complex subtraction (const Complex&);
Complex multiplication (const Complex&);
private:
Complex.h
You should write Complex.cpp and main
code separately.
double getReal() { return real; }
double getImaginary() { return imaginary; }
void print();
double real;
double imaginary;
Sample outputs
CLASS
Enter real and imaginary number for el: 24
Enter real and imaginary number for cl: 39
c1 = 2 + 4i
c2 = 3 + 91
Sum
Subtraction
: 5+131
-1-51
Multiplication : -30 + 301
Enter real and imaginary number for cl: -27
Enter real and imaginary number for el: 3 10
c1 = -2 + Ti
c2 = 3 + 101
: 1+ 171
Sum
Subtraction
: -5 + -3i
Multiplication: -76 + 1i

Transcribed Image Text:Define a class for complex numbers. A complex number is a number of
the form a + bi, where a and b are double type data and I is a number
that represents the quantity √-1.
Class name is Complex.
Name the private member variables real and imaginary.
Default constructor that initializes an object to 0 (that is, 0 + 0i)
Constructor with two parameters
Other functions (See next slide)
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage

C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr

EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage

C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr

C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning

Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning

Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,