The problem is that a geometry object can be either one of the primitive types: points, lines, triangles and quads so; in essence, the data structure is a list of objects which contain one of the aforementioned types, not following any precondition to linking objects.
The workaround implemented by me for this would have generic pointers and a type variable which specifies what type it is so proper cast is done.
struct point{...};
struct line{...};
struct triangle{...};
struct quad{...};
class Geometry
{
short type; //POINT, LINE, TRIANGLE OR QUAD
void *geometryData; //Pointer to structure of type specified.
Geometry *next;
}
Is this a good approach or is there a better one for working with polymorphism, maybe using templates?
Appreciate all help given.
Best regards!