Question: USE C++ AND DONT USE THE .this OPERATOR Consider a class Triangle with the following private data members: id (int), base (float) and height (float).

USE C++ AND DONT USE THE ".this" OPERATOR

Consider a class Triangle with the following private data members: id (int), base (float) and height (float).

You should create 2 constructors:

1. Default - assign a value for the id attribute

2. Non-Default (with parameters): assign id, height, and base

You should also create getters and setters to retrieve and modify the values of your private variables, all of them.

Create 3 objects: one using the default constructor and two passing the height and base. In the first object use the setters to assign values to your attribute. All attributes values must be provided by the user for the last two objects.

Create a function, part of the class Triangle, which has the following signature: void compareTriangle(float base, float height, int id, Triangle obj2, Triangle obj3)

For the first three parameters, use getters to pass the attributes of the first triangle. For the last two, you can pass the actual objects. This function should show the area of all triangles on screen (specify all attributes). You should implement a private function called calculateArea inside Triangle class to perform this operation (calculate area). Design a basic function that only needs base and height to operate.

After obtaining the area of all triangles, show the one with the highest value, with ID and are value.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!