What is the difference between compile-time and runtime polymorphism?

Last updated 21 June 2026

  • Compile-time (static) polymorphism resolves calls during compilation via overloading and templates. It has no runtime overhead and can be inlined.

  • Runtime (dynamic) polymorphism uses virtual functions through base pointers/references, dispatching via a vtable based on the actual object type.

  • Trade-off: static is faster, dynamic is more flexible and used when behavior depends on the runtime type.

  • https://github.com/crazyguitar/cppcheatsheet
All C++ interview questions