OOP using C++
Inheritance
, Inheritance Concept
class Rectangle{
Polygon private:
int numVertices;
float *xCoord, *yCoord;
public:
Rectangle Triangle void set(float *x, float *y, int nV);
float area();
};
class Polygon{ class Triangle{
private: private:
int numVertices; int numVertices;
float *xCoord, *yCoord; float *xCoord, *yCoord;
public: public:
void set(float *x, float *y, int nV);
void set(float *x, float *y, int nV);
float area();
}; 2
};
, Inheritance Concept
class Polygon{
Polygon protected:
int numVertices;
float *xCoord, float *yCoord;
public:
void set(float *x, float *y, int nV);
Rectangle Triangle };
class Rectangle{
protected:
class Rectangle : public Polygon{ int numVertices;
public: float *xCoord, float *yCoord;
public:
float area();
void set(float *x, float *y, int nV);
}; float area();
3
};