What is the difference between compile-time and runtime polymorphism?
- A Templates resolve at compile time with no runtime cost; virtual functions resolve through a vtable at runtime
- B Templates are slower
- C Virtual functions resolve at compile time
- D They are the same mechanism
Answer
Templates resolve at compile time with no runtime cost; virtual functions resolve through a vtable at runtime
Templates allow inlining but increase compile time and binary size. Virtual functions allow heterogeneous collections behind one base pointer.





