recursive virtual functions

Code:

`class Derivative_Function;`

class Factor_Expression : public Factor;

class Derivative_Function {

Factor_Expression derive(Factor&);

}

class Factor_Expression {

Factor_Expression sub_derive(Factor&);

}

OK, here's my problem:

derive() operates on a Factor& without needing to specify what kind of Factor it is. But in the end, there are a few specific changes that need virtual functions.

So I created sub_derive(). My problem is that I need to call derive() from sub_derive() for the Factor_Expression class because of its recursive nature. (sub_derive() is called at the very end of derive().)

I hope that's clear...

The Derivative_Function object is inaccessable from sub_derive, so derive() can't be called again. So, what I want to do is organize sub_derive() into the class Derivative_Function to correct this problem.

How can I do this without resorting to a switch-case typeid() comparison?