
Concept explainers
(Complex Class) Consider class Complex shown in Figs. 18.14–18.16. The class enables operations on so-called complex numbers. These are numbers of the form realPart
- Modify the class to enable input and output of complex numbers via overloaded >> and << operators, respectively (you should remove the print function from the class).
- Overload the multiplication operator to enable multiplication of two complex numbers as in algebra.
- Overload the == and != operators to allow comparisons of complex numbers.
After doing this exercise, you might want to read about the Standard Library’s complex class (from header
Fig. 18.14 Complex class definition.
Fig. 18.15 Complex class member-function definitions.
Fig. 18.16 Complex class test

Want to see the full answer?
Check out a sample textbook solution
Chapter 18 Solutions
C How To Program Plus Mylab Programming With Pearson Etext -- Access Card Package (8th Edition)
Additional Engineering Textbook Solutions
Starting Out With Visual Basic (8th Edition)
SURVEY OF OPERATING SYSTEMS
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Mechanics of Materials (10th Edition)
INTERNATIONAL EDITION---Engineering Mechanics: Statics, 14th edition (SI unit)
Electric Circuits. (11th Edition)
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT


