Question: TriangleHeap.h / . cpp create triangle class where the members are stored on the heap ( dynamic float ) the triangle should have private mBase
TriangleHeap.hcpp create triangle class where the members are stored on the heapdynamic float the triangle should have private mBase and mHeight members, two public set methods to allow main to change each of these members' values. These should NOT receive float, just float parameters for the data to set your datas to Public method GetArea that returns the area, this does not return a float just a float data result. Remember, the dynamic Triangle must fully implement the rule of Because the copy constructor and default constructor are exclusive only one is called you must new your members in the dynamic triangle either in both constructors or in the member declaration area of your class.
Then in main declare two TriangleHeap variables and set their memebers to whatever two different values you want. Then declare a vector and add the two triangles to is using its pushback method. Finally loop thru the vector and print each triangle's area to the screen. The vectors should NOT contain pointers
the getArea is not returning the correct area for the given height and base...
please look and tell me where I am going wrong so that I can get the program to print the correct area... it is all about pointers... perhaps Im not using themunderstanding them correctly
class TriangleHeap
private:
float mBase;
float mHeight;
public:
TriangleHeapfloat base float height ;
TriangleHeapconst TriangleHeap& other;
~TriangleHeap;
TriangleHeap& operatorconst TriangleHeap& other;
void SetBasefloat base;
void SetHeightfloat height;
float GetArea const;
;
#include "TriangleHeap.h
TriangleHeap::TriangleHeapfloat base, float height :mBasenew floatbase mHeightnew floatheight
TriangleHeap::TriangleHeapconst TriangleHeap& other:mBasenew floatothermBase mHeightnew floatothermHeight
TriangleHeap::~TriangleHeap
delete mBase;
delete mHeight;
TriangleHeap& TriangleHeap::operatorconst TriangleHeap& other
if this &other
mBase othermBase;
mHeight othermHeight;
return this;
void TriangleHeap::SetBasefloat base
mBase base;
void TriangleHeap::SetHeightfloat height
mHeight height;
float TriangleHeap::GetArea const
float area mBasemHeight;
return area;
TriangleHeap heap heap;
std::vector heapVector;
float base height base height;
std::cout "Enter base for first TriangleHeap: ;
std::cin base;
std::cout "Enter Height for first TriangleHeap: ;
std::cin height;
heapSetBasebase;
heapSetHeightheight;
std::cout "Enter base for second TriangleHeap: ;
std::cin base;
std::cout "Enter height for second TriangleHeap: ;
std::cin height;
heapSetBasebase;
heapSetHeightheight;
heapVector.pushbackheap;
heapVector.pushbackheap;
std::cout
Areas of TriangleHeap:" std::endl;
for sizet i ; i heapVector.size; i
std::cout "Triangle i:
tArea: heapVectoriGetArea std::endl;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
