Question: C + + #include using namespace std ; class Polygon { protected: int width, height ; public: void setValues ( int w , int h
C #include
using namespace std ;
class Polygon
protected:
int width, height ;
public:
void setValues int w int h width w ; height h ;
;
class Rectangle: public Polygon
public:
int area return width height ;
;
class Triangle: public Polygon
public:
int area return width height ;
;
int main
Rectangle rect ; rect.setValues ;
Triangle trgl ; trglsetValues ;
cout "Rectangle area : rect.area endl ;
cout "Triangle area : trglarea endl ;
return ;
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
