#ifndef TRIANGLE_H
#define TRIANGLE_H
#include "shape.h"
#include <iostream>
#include <cmath>
usingnamespace std;
class Triangle:public Shape{
private:
Point p1;
Point p2;
Point p3;
public:
Triangle(Point p1_set, Point p2_set, Point p3_set);
Triangle();
void set(int i, Point p);
Point get(int i);
};
#endif
However, enven though I have correctly code the functions such as 'translate' in the definition file of Triangle, the compiler does not recognize that translate has been defined in the header file of base class.
Because with your current definition of the Shape class, it requires the implementation of each of these methods. If, however, you believe that a "Shape" is too nebulous to be defined or instantiated, then you need to make at least one of its functions a pure virtual function. This would define Shape as an abstract class. For each function you believe shouldn't be implemented at this level, you should do something like:
virtualvoid myFunction() = 0;
For instance, if you believe perimeter, print, println, and translate should not be implemented at the Shape level, then you need to do the following: