USE " Polymorphism " WHILE SOLVING PROBLEM IF NOT FOLLOWED WILL BE GIVEN A DOWNVOTE. AND MATCH OUTPUT AND INPUT AS IT IS. NO INTERNET COPY PASTE ANSWER. ------------------------------------------------- Develop a program to overload binary operators. The class Complex has the following public attributes Data type Variable name int real int imaginary Include default constructor to initialize real and imaginary values to 0 Include the following functions in the Complex class and overload the binary operators Member function Function description void getvalue() This function is used to read inputs Complex operator+(const Complex& obj) This function will add the real and imaginary parts and return the complex object of added values Complex operator-(const Complex& obj) This function will subtract the real and imaginary parts and return the complex object of subtracted values void display() This function will display the result value ​​​​ In main() function invoke the operator overloading by creating objects for the Complex class. Below statements should be printed in the main() function itself Enter the value of Complex Numbers a,b : Enter the value of Complex Numbers a,b : Input Values : Result :   Sample Input and Output : [All texts in bold represents input and rest represents output statements] Enter the value of Complex Numbers a,b :4 5 Enter the value of Complex Numbers a,b :7 8 Input Values : Output Complex number : 4+5i Output Complex number : 7+8i Result : Output Complex number : 11+13i Output Complex number : -3-3i

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

USE " Polymorphism " WHILE SOLVING PROBLEM IF NOT FOLLOWED WILL BE GIVEN A DOWNVOTE.

AND MATCH OUTPUT AND INPUT AS IT IS. NO INTERNET COPY PASTE ANSWER.

-------------------------------------------------

Develop a program to overload binary operators.

The class Complex has the following public attributes

Data type Variable name
int real
int imaginary

Include default constructor to initialize real and imaginary values to 0

Include the following functions in the Complex class and overload the binary operators

Member function Function description
void getvalue() This function is used to read inputs
Complex operator+(const Complex& obj)

This function will add the real and imaginary parts
and return the complex object of added values

Complex operator-(const Complex& obj)

This function will subtract the real and imaginary parts
and return the complex object of subtracted values

void display() This function will display the result value

​​​​
In main() function invoke the operator overloading by creating objects for the Complex class. Below statements should be printed in the main() function itself

  • Enter the value of Complex Numbers a,b :
  • Enter the value of Complex Numbers a,b :
  • Input Values :
  • Result :

 

Sample Input and Output :
[All texts in bold represents input and rest represents output statements]

Enter the value of Complex Numbers a,b :4 5
Enter the value of Complex Numbers a,b :7 8
Input Values :
Output Complex number : 4+5i
Output Complex number : 7+8i
Result :
Output Complex number : 11+13i
Output Complex number : -3-3i

 

Expert Solution
steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY