Problem Statement Create a class named Circle with a single private member variable called radius of type (int. Add getter, setter and area functions. Overload the operators and the stream operator <<. Write a program that creates two objects of type Circle of radius 15 and 10. Add both, subtract the second from the first and print out both results using the overloaded stream insertion operator <<. Partial Solution Please try to implement the full source code #include your IDE first. The solution is partially provided below. Fill in the blanks to complete the missing parts and make sure to not add an empty space before and after the answer.

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

C++

Question 1
Problem Statement
Create a class named Circle with a single private member variable called radius of type (int. Add getter, setter and area functions.
Overload the operators
and the stream operator <<.
Write a program that creates two objects of type Circle of radius 15 and 10. Add both, subtract the second from the first and print out both results using the overloaded stream insertion operator <<.
Partial Solution
Please try to implement the full source code in your IDE first. The solution partially provided below. Fill in the blanks to complete the missing parts and make sure to not add an empty space before and after the answer.
#include <iostream>
using namespace std;
}
private:
int radius;
public:
}
//Constructor overloading
Circle(int radius);
//Member function area, it output the area of a circle
area();
}
//Getter and setter
}
//Operator overloading
Circle operator + (const Circle& c);
//Constructure overloading
Circle :: Circle(int radius) {
this->radius = radius;
}
// Member function
int Circle::getRadius() const {
double
//Friend function and operator overloading
return
}
void Circle :: setRadius(int r) {
this->radius=r;
getRadius() const;
setRadius(int);
}
int main()
{
operator (const Circle& c);
}
//operator overloading
Circle Circle :: operator
int newRadius = this->getRadius() + c.getRadius();
Circle
return newCircle;
ostream& operator<<(ostream &out, Circle &c);
Circle c20
//Friend function, operator overloading
Circle c1(15):
cout << "C1 is " << c1:
Circle Circle ::
- (const Circle& c) {
int newRadius = this->getRadius() - c.getRadius();
Circle newCircle(newRadius);
return [newCircle];
Circle
cout << "C2 is " << c2;
->radius:
3.14* (this->radius *this->radius);
[return] 0;
out << "Radius: " << c.getRadius() << " Area : " << c.area() << "\n";
return out;
area() {
& operator << (ostream &out, Circle &c) {
Circle add c1 + c2:
cout << "c1 + c2 is " <<
cout << "c1-c2 is " << sub;
(const Circle& c) {
|);
= c1-c2;
);
Transcribed Image Text:Question 1 Problem Statement Create a class named Circle with a single private member variable called radius of type (int. Add getter, setter and area functions. Overload the operators and the stream operator <<. Write a program that creates two objects of type Circle of radius 15 and 10. Add both, subtract the second from the first and print out both results using the overloaded stream insertion operator <<. Partial Solution Please try to implement the full source code in your IDE first. The solution partially provided below. Fill in the blanks to complete the missing parts and make sure to not add an empty space before and after the answer. #include <iostream> using namespace std; } private: int radius; public: } //Constructor overloading Circle(int radius); //Member function area, it output the area of a circle area(); } //Getter and setter } //Operator overloading Circle operator + (const Circle& c); //Constructure overloading Circle :: Circle(int radius) { this->radius = radius; } // Member function int Circle::getRadius() const { double //Friend function and operator overloading return } void Circle :: setRadius(int r) { this->radius=r; getRadius() const; setRadius(int); } int main() { operator (const Circle& c); } //operator overloading Circle Circle :: operator int newRadius = this->getRadius() + c.getRadius(); Circle return newCircle; ostream& operator<<(ostream &out, Circle &c); Circle c20 //Friend function, operator overloading Circle c1(15): cout << "C1 is " << c1: Circle Circle :: - (const Circle& c) { int newRadius = this->getRadius() - c.getRadius(); Circle newCircle(newRadius); return [newCircle]; Circle cout << "C2 is " << c2; ->radius: 3.14* (this->radius *this->radius); [return] 0; out << "Radius: " << c.getRadius() << " Area : " << c.area() << "\n"; return out; area() { & operator << (ostream &out, Circle &c) { Circle add c1 + c2: cout << "c1 + c2 is " << cout << "c1-c2 is " << sub; (const Circle& c) { |); = c1-c2; );
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Linked List Representation
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.
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