Suppose I have something like the following:
class Point : geometry {
...
Point(double x, double y) {
}
double distanceTo(Line) {
}
double distanceTo(Point) {
}
}
class Line : geometry {
...
Line(double x, double y, double slopex, double slopey) {
}
double distanceTo(Line) {
}
double distanceTo(Point) {
}
}
struct point_t {
double x, y;
}
struct line_t {
double x, y, slope_x, slope_y;
}
struct Geom_Object_t {
int type;
union {
point_t p;
line_t l;
} geom;
}
I am wondering what the best way to define a dispatch table for a function like
double distanceTo(Geom_Object_t * geom1, Geom_Object_t * geom2) {
}
The classes are written in C++, but the distanceTo function and the struct must be externed to C
thanks