I'm currently working on a program in which I have a class called IDeviceInfo. About 20 other classes derive from it, so I put a pure virtual function called ResetVariables() in IDeviceInfo, which is then overridden individually in all the different derived classes to reset the required internal variables. I then tried to call ResetVariables from the constructor of IDeviceInfo, so that I wouldn't have to call ResetVariables 20 times in the constructors of the derived classes. This doesn't work though, and results in an error. (Calling a pure virtual function) I have a similar situation in another section of my code where I try to call a pure virtual function from a constructor of a base class as well.
How can I circumvent this problem?
As I mentioned above, I am aware that I could just call ResetVariables() 20 times from the constructors of each of the derived classes, but this is not practical and not what I am looking for, for reasons that are too long to explain here. I am also aware that I could abolish the ResetVariables() function and simply put all the 'resetting' code into each of the constructors. I cannot do this however as I need to be able to reset the variables in an instance of any of the 20 derived classes using polymorphism (ie using a pointer to an IDeviceInfo).
Thank you in advance,