Interface-based Programming in C++

Abstract

In many object oriented literature runtime polymorphism is often the only way mentioned to realize interface-based programming. In comparison to other languages, C++ offers more than just that. In C++ interface-based programming can also be achieved through link-time or compile-time polymorphism. This paper will show how interface-based programming can be done in C++ when using these three types of polymorphism. The different approaches are compared with each other at different compiler optimization levels. The paper will also show that compiler optimization mechanisms like inlining and devirtualization have been improved to minimize the overhead caused by dynamic dispatch even more.