I have a couple of classes derived from a parent class, and each of these classes and the parent have their own header files and cpp's. The derived class headers include the header of the parent. The main cpp file needs to include all headers; parent class, and the two derived class headers. I added an include guard for the parent header file in the main cpp, but since both the derived class headers include the parent header file, I am given an error during compilation. How can I fix this problem without merging the derived classes into one single header file?
I'm adding various code snippets here which are basically separate files on my system. This is just test code so you may see some weird function implementations.
#include "polygon.h"
class Triangle : public Polygon
{
private:
int base, height;
public:
Triangle();
Triangle(int t_base, int t_height, int t_sides);
int Perimeter();
double ComputeArea();
};