struct A {
...
}:
struct B : public A {
...
}:
struct C : public A {
...
}
bool same_sub_class(A * a1, A * a2){
// Fill this in to return true if a1 and a2 are
// of the same concrete class
}
编辑:
当我查看我的应用程序时,我需要从上面略微不同的东西。我需要能够按它们的 type_id 分组实例。
顺便说一下,我有一个小的符号代数系统,因此为了进行操作,有时需要知道类类型以进行排序和重排表达式。
因此,给定一个指向实例的指针向量,如何按其 type_id 将它们分组。我需要能够哈希 type_id 或为每个类生成唯一的整数。