Question: i am having trouble with my code that is in bold when i run the prgram i get errors and any help would be highly
i am having trouble with my code that is in bold when i run the prgram i get errors and any help would be highly apreciated
#include
class Rectangle { public: Rectangle(float length = 0, float width = 0); void set(float length, float width); void get(float &length, float &width); string getType(); // Returns RECTANGLE float area(); private: float len, wid; }; class Triangle { public: Triangle(float base = 0, float height = 0); void set(float base, float height); void get(float &base, float &height); string getType(); // Returns TRIANGLE float area(); private: float b, h; }; Rectangle::Rectangle(float length, float width) { len = length; wid = width; }
void Rectangle::set(float length, float width) { len = length; wid = width; } void Rectangle::get(float &length, float &width) { length = len; width = wid; } std::string Rectangle::getType() { return "RECTANGLE"; } float Rectangle::area() { return len*wid; }
Triangle::Triangle(float base, float height) { b = base; h = height; } void Triangle::set(float base, float height) { b = base; h = height; } void Triangle::get(float &base, float &height) { base = b; height = h; } std::string Triangle::getType() { return "TRIANGLE"; } float Triangle::area() { return 0.5*b*h; } template
template
float b, h, len, wid;
cout << "Enter the base and height for a triangle: "; cin >> b >> h;
cout << "Enter the length and width for a rectangle: "; cin >> len >> wid;
Rectangle rec(len, wid); Triangle tri(b, h);
display(rec); display(tri);
if (equalArea(rec, tri)) cout << "The two objects are of equal area" << endl; else cout << "The two objects are not of equal area" << endl;
cout << "There are" << maxFill(tri,rec)<<"triangles that will fit in the rectangle"; cout << "There are" << maxFill(rec,tri)<< "rectangles that will fit in the triangle"; system("pause"); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
