Question: Add a second class called RegularPolygon, which will inherit the characteristics of the Figure class. Add the following elements. Attributes: - - apothem - -

Add a second class called RegularPolygon, which will inherit the characteristics of the Figure class. Add the following elements.
Attributes:
-- apothem
--sidemeasurement
Methods:
--get and set the two attributes
-- calculate perimeter
-- calculate area
Add an example of an octagon and a pentagon to the main file.
Here is the code to complete.
Figure.h
#ifndef FIGURE_H
#define FIGURE_H
#include
using namespace std;
class figure
{
public:
//overload
Figure();
Figure(string, int);
virtual ~Figure();
void setName(string);
string getName();
void setNoSides(int);
int getNoSides();
protected://access to your children's class
string name;
int noSides;
private:
};
#endif // FIGURE_H
/////////////////////////////////////////////////////////
Figure.cpp
#include "Figure.h"
Figure::Figure()
{
noSides=1;
name="ND";
}
Figure::Figure(string x, int y){
noSides=y;
name=x;
}
Figure::~Figure()
{
//doctor
}
void figure::setName(string x){
name=x;
}
string Figure::getName(){
return name;
}
void figure::setNoSides(int x){
noSides=x;
}
int Figure::getNoSides(){
return noSides;
}

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!