#include #include #include using namespace std; class Complex { private: int real; int imaginary;

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

QUESTION PROVIDED IN ATTACH IMAGE KINDLY SEE. PROVIDE OUTPUT AS IT IS SHOWN IN QUESTION.

 

AND BELOW TEMPLATES PROVIDED CHECK THIS BEFORE MAKING SOLUTION ( main.cpp , complex.cpp  )

----------------- TEMPLATES BELOW FOR SOLUTION -----------------------

 

complex.cpp

#include<cstring>
#include<iostream>
#include<string>
using namespace std;

class Complex
{
private:
int real;
int imaginary;


//Fill your code here

};

 

Main.cpp

#include<cstring>
#include<iostream>
#include<string>
#include "Complex.cpp"
using namespace std;
int main()
{

//fill your code here
}
Develop a program to overload binary operators.
The class Complex has the following public attributes
Data type
int
int
Variable name
real
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
void getvalue()
Function description
This function is used to read inputs
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
Complex operator-(const Complex& obj)
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:45
Enter the value of Complex Numbers a,b:78
Input Values:
Output Complex number:4+5i
Output Complex number :7+8i
Result :
Output Complex number :11+13i
Output Complex number : -3-3i
Transcribed Image Text:Develop a program to overload binary operators. The class Complex has the following public attributes Data type int int Variable name real 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 void getvalue() Function description This function is used to read inputs 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 Complex operator-(const Complex& obj) 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:45 Enter the value of Complex Numbers a,b:78 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 4 steps with 1 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