I have a class called "Animal" which is a super-class and pure polymorphic. I have other classes "Dog", "Cat", "Hamster" etc.. that all inherit from the "Animal" class.
In a program, I need to include all of the sub-classes (dog, cat, hamster) however, when I do:
#include "Hamster.h"
#include "Dog.h"
...
...
I get the error:
previous definition of ‘class Animal’
Is there a way to prevent this?
P.S. I have thought about doing a:
#ifdef
But, for if the class get's used, then include it. E.g. if the program is trying to instigate a Cat class, then, carry out the include.
Sorry if this isn't explained well.