use of virtual for functions

Dear all,

This question relates to my understanding of virtual functions.

Class PairGranHertzHistory is a child of PairGranHookeHistory that redefines the compute, settings and single functions.
But when I looked through pair_gran_hooke_history.h I spotted that compute and settings are virtual functions but single is not. Is there a reason for not writing virtual single too? Is there a subtle difference in the way they are used/defined, or is it just a forgotten word?

Thank you,

George

It should have been labeled virtual. Common practice is to only label a function in a derived class as virtual, when it is overidden. I have once argued that it would be good practice to apply virtual always, but failed to convince Steve.
Axel.

Thanks Axel!

And to push this conversation a bit further- what is the danger associated with single not being virtual in this case?
Is there any way there could be confusion and the wrong code for the function called?

Regards,
George

The danger is that it cannot be cleanly overidden in a derived class.

Axel.

Added "virtual" to the parent *.h file.

Steve