This is a basic C++ copy constructor question. Q. Create and test a getLargerCir
ID: 3707172 • Letter: T
Question
This is a basic C++ copy constructor question.
Q. Create and test a getLargerCircle () function that returns a larger circle by accepting two circle objects representing a circle. Where is the copy creator called?
Circle GetLargerCircle (Circle c1, Circle c2) {
...
}
Estimated results :
===========================================
Circle (10)
Circle (20)
The larger circle is as follows.
Circle (20)
=============================================
Use this Circle class:
class Circle
{
public:
int x, y;
int radius;
Circle() :x{ 0 }, y{ 0 }, radius{ 0 } {}
Circle(int x, int y, int r) : x{ x }, y{ y }, radius{ r } {}
void print() { cout << "Circle(" << radius << ")" << endl; }
};
Explanation / Answer
#include using namespace std; class Circle { public: int x, y; int radius; Circle() :x{ 0 }, y{ 0 }, radius{ 0 } {} Circle(int x, int y, int r) : x{ x }, y{ y }, radius{ r } {} void print() { coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.