3 ms·
I once got this question from an interviewer, who was a senior dev on the project: "What is a vtable?" My answer was that it was the way in which a C++ compil
by Luyt 14y ago
I once got this question from an interviewer, who was a senior dev on the project:
"What is a vtable?"
My answer was that it was the way in which a C++ compiler makes it possible to do polymorphism (calling base member methods through pointers to derived classes; virtual functions). The interviewer didn't agree with me and said that vtables have nothing to do with polymorphism and moved on to another question (about :: scoping). I didn't start to argue with him, and I got the job.
- jpatte 14y agoThat may be because there are several forms of polymorphism. What you had in mind was subtype polymorphism (aka substitution), while he might have had another form in mind like parametric polymorphism (aka generics). http://en.wikipedia.org/wiki/Polymorphism_(computer_science) http://en.wikipedia.org/wiki/Polymorphism_(computer_science) Btw I assume you meant "calling derived member methods through pointers to base classes" instead.
- Luyt 14y agoYes, you are correct. I meant something like: animal->move_random(), where animal can be a dog, cat, or even a bird (with an extra z coordinate ;-).