"why can the compiler not find this out at compile time" It can in some cases, look up "devirtualization". Also there are some alternatives to virtual functions that do this at compile-time (CRTP).
↧