假设我有以下内容:
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;
}
我想知道为类似的函数定义调度表的最佳方法是什么
double distanceTo(Geom_Object_t * geom1, Geom_Object_t * geom2) {
}
这些类是用 C++ 编写的,但是 distanceTo 函数和结构必须外部到 C
谢谢