+ 2
Runtime polymorphysm mechanism
Hi I am aware about vptr and vtable. I am curious to know what all happens at run time and compile time. ? Does vptr and vtable are build at compile time only ?
1 Odpowiedź
+ 2
The compiler at compile time sets up one VTABLE each for a class having virtual functions as well as the classes that are derived from classes having virtual functions. A VTABLE contains entries that are function pointers to the virtual functions that can be called by the objects of the class. Answer from: https://www.google.com/url?sa=t&source=web&rct=j&url=https://www.softwaretestinghelp.com/runtime-polymorphism-in-cpp/amp/&ved=2ahUKEwjs0YKC94_nAhWNB50JHXANADMQFjABegQIDRAK&usg=AOvVaw2uAw7OAt6IRtbZKh0201TA&cf=1