magos, you actually can check types, with some restrictions though. By using typeid you can compare the type of two objects that have a virtual method.
tejj, you could use rtii. But you might also want to consider something like this.
Code:
class GeomVisitor {
public:
virtual void visit(Quad* quad) = 0;
virtual void visit(GeoObj* geomObj) = 0;
};
// ... //
class ScreenRender : public GeomVisitor {
public:
// ... //
virtual void visit(Quad* quad);
virtual void visit(GeoObj* geoObj);
};
class GeomObj {
public:
virtual void accept(GeomVisitor* v) {
v->visit(this);
}
};
class Quad : public GeomObject {
public:
virtual void accept(GeomVisitor* v) {
v->visit(this);
}
};
// ... //
ScreenRender render;
for (Quad* o = scn.obj; o; o=o->next) {
o->accept(&render);
}
You'd then pay the price of two virtual calls, comparative to the one virtual call and one comparison you'd have using typeid(which requires accessing the typeid/virtual table anyhow).