Why don't you just define the 'setError' method as virtual or pure virtual in classB, then change it in classA. Any classA object cast into a classB will then have access to classA's setError