I came across a very strange C++ code where adding a override keyword in header file seems to alter the code flow.
I was debugging a issue where a virtual function was being invoked. Strangely, the code jumped to some different virtual function in derived class. There was nothing in call stack so I assume something is messed up with vtable. After some trial and error I saw that the function where my code was jumping did not have override keyword mentioned. I added it and it seem to fix issue of control being jumped into that function.
What I knew till date is that override is just a syntactic sugar. If so, can anyone who has deep understanding of vtables, overrides help me to understand what might be happening?
- virtual string prefEnv() const;
- virtual string prefEnv() const override;
Aucun commentaire:
Enregistrer un commentaire