Why do I get a compilation error when I call a base-class function with a pointer to a pointer to an inherited class?
Example:
class cFoo {};
class cBar : public cFoo {};
void func1(cFoo *) {} // base class
void func2(cFoo **) {} // base class
void main(void)
{ cBar bar, *pbar; // inherited class
func1(&bar); // compiles OK
func2(&pbar); // fail
func2(dynamic_cast<cFoo**>(&pbar)); // 'class cFoo ** ' : invalid target type for dynamic_cast
}
How do I get around this?