You can't check for override of virtual function portably.
You need to bring the knowledge to the Solver
, preferably via type as opposed to run-time flag.
One (type-based) way is to check for presence or absence of a interface, via dynamic_cast
.
A probably better way is to provide overloads of solve function, in your case the Solver
constructor.
Probably better advice could be given if you provided a more concrete description of the problem. It does remind of typical situation where someone (1) needs to solve some problem P, (2) envisions technical approach X as a solution to P, (3) discovers that X doesn't cut it, and (4) asks how to make X work for a vague description of P, or even for some unrelated problem Q. The details of original problem P will often suggest a much better solution than X, and the problems of making X work, irrelevant to solving P.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…