Question
#include #include using namespace std; class Shape { public: virtual string getType() = 0; virtual double getPerimeter() = 0; virtual double getArea() = 0; };
#include
class Shape { public: virtual string getType() = 0; virtual double getPerimeter() = 0; virtual double getArea() = 0; };
//Implement class Triangle here
//Implement class Circle here
void describeShape(Shape &s) { double a = s.getArea(); double p = s.getPerimeter(); string t = s.getType();
cout
/** * Determines the larger are between the two Shape objects * The larger area is stored in result */ void largerArea(Shape &a, Shape &b, double *result) { //Complete the function }
int main() { Triangle t; Circle c; c.setDims(2); t.setDims(3, 4, 5);
describeShape(t); describeShape(c);
double result; largerArea(t, c, &result); cout
t.setDims(6, 8, 10); describeShape(t); describeShape(c); largerArea(t, c, &result); cout
return 0; } in c++
Question 2: Download lab12 Q2.cpp. The following function accepts objects by reference and indicates the object that has larger area by storing a value in the variable pointed to by result. Implement the function using the classes defined in Question 1. ak *Determines the larger area between two Shape objects * The larger area is stored in result void largerArea(Shape &a, Shape &b, double 'result); . Use the given driver program to produce the following output: his Triangle has a perimeter of: 12 and an area of: 6 his circle has a perimeter of: 12.5664 and an area of: 12.5664 he larger area is: 12,5664 his Triangle has a perimeter of: 24 and an area of: 24 is Circle has a perimeter of: 12.5664 and an area of: 12.5664 The larger area is: 24 ress any key to continue. Note, largerArea) must not produce terminal output, the value must be passed to the caller through the result pointer variable. SubmissionStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started