Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

More Books

Students also viewed these Databases questions

Question

Language in Context?

Answered: 1 week ago