It sounds like the Tracker class would best be a template instead of being derived from a common ancestor:
template<typename Element>
class Tracker {
public:
void add(Element* p);
private:
vector< Element* > vec;
};
typedef Tracker<Base> BaseTracker;
typedef Tracker<Derived> DerivedTracker;
You could then add a specialization of the add() method that uses Derived's special features:
template<>
void Tracker<Derived>::add(Derived* p) {
p->spec();
vec.push_back(p);
}
sth
2010-01-30 16:03:37