0

Hi again and thanks in advance ! Last question !

I have to create a class called polygon (not normal) that has in private the number of sides and the length of each side and in public

that has 2 constructors (the one has as variables the number and each length (how is that possible), getlength (perimeter) , setpolygon , getedge (of a k side) .

Also then i have to make a subclass called rectangle that has constructor with length,height

getlength again ,getarea ...

What does rectangle inherits from polygon ?

Here's the code of the polygon class

but i have no idea what i'm supposed to create in that way dynamically

here's the code !

```
#ifndef POLYGON_H
#define POLYGON_H
class Polygon
{
private :
int size;
int *len;
public:
Polygon();
Polygon(int k,int *l);
~Polygon();
int getLength();
void setPolygon(int k,int *l);
int getEdge(int k);
};
#endif
```

polygon.cpp

```
#include "polygon.h"
Polygon::Polygon()
{
size=0;
}
Polygon::~Polygon()
{
delete [] len;
}
Polygon::Polygon(int k,int *l)
{
size=k;
len=new int[size];
for(int i=0;i<size;i++)len[i]=l[i];
}
int Polygon::getLength()
{
int sum=0;
for(int i=0;i<size;i++) sum+=len[i];
}
void Polygon::setPolygon(int k,int *l)
{
size=k;
len=new int[size];
for(int i=0;i<size;i++) len[i]=l[i];
}
int Polygon::getEdge(int k)
{
return len[k];
}
```

main.cpp

```
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
system("PAUSE");
return EXIT_SUCCESS;
}
```

*Edited 4 Years Ago by pyTony*: Code format mess clean up try, be careful next time!