C++ How to Program (10th Edition)
C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 9, Problem 9.5E

(Complex class) Create a class called complex for performing arithmetic with complex numbers. Write a program to test your class. Complex numbers have the form

realpart+imaginarypart * i

where i is 1

Use double variable to represent the private data of the class. Provide a constructor that enables an object of this class to be initialized when it’s declared. The constructor contains default values in case no initializes are provided. Provide public member function that perform the following tasks:

  1. Add- Adds two complex numbers: the real parts are adaded together and the imaginary parts are added together.
  2. Subtract- subtract two complex numbers: The real part of the right operand is subtracted from the real part of the left operand, and the imaginary part of the right operand is susbtracted from the imaginary part of the left operand.
  3. toString: Return a string representation of a complex number in the form (a, b), where a is the real part and b is the imaginary part.

In chapter 10, you’ll learn how to overload +, - aqnd << so you cvan write expressions like a+ b and a- b and cout <<a to add, subtract and output Complex objects. [Note: The C++ Standard Library provides its own class complex-number arithmetic. For information on this class, visit http://en.cppreference.com/w/cpp/numeric/complex.]

Blurred answer
Students have asked these similar questions
I need help creating the network diagram and then revising it for the modified activity times.
Activity No. Activity Time (weeks) Immediate Predecessors 1 Requirements collection 3 2 Requirements structuring 4 1 3 Process analysis 3 2 4 Data analysis 3 2 5 Logical design 50 3,4 6 Physical design 5 5 7 Implementation 6 6 c. Using the information from part b, prepare a network diagram. Identify the critical path.
Given the following Extended-BNF grammar of the basic mathematical expressions:  Show the derivation steps for the expression: ( 2 + 3 ) * 6 – 20 / ( 3 + 1 ) Draw the parsing tree of this expression. SEE IMAGE
Knowledge Booster
Background pattern image
Computer Science
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.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
What is Abstract Data Types(ADT) in Data Structures ? | with Example; Author: Simple Snippets;https://www.youtube.com/watch?v=n0e27Cpc88E;License: Standard YouTube License, CC-BY