dimanche 21 juillet 2019

Virtual function behavior in template classes in C++

I have the following code to create a std::thread wrapper.

The un-intuitive behaviour is that if I keep the last line of main then I get the overriden Run method, whereas if I remove the last statement, I get the base class Run method despite creating a derived class object. What is the possible reason for this?

The behaviour is identical in MSVS 2019 and g++ as well.

Note: The code is somewhat simplified and logs/additional checks removed to keep it short.

Aucun commentaire:

Enregistrer un commentaire