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) 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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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

 

MAKE CODE AS IT RUNS FOR OTHER RANDOM OUTPUT TO.

 

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

 

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

 

main.cpp

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

//fill your code here
}

 

complex.cpp

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

class Complex
{
private:
int real;
int imaginary;


//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 5 steps with 4 images

Blurred answer
Knowledge Booster
Introduction to Template
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education