Why can't run-time polymorphism be solved at compile time?

前端 未结 6 811
情书的邮戳
情书的邮戳 2020-12-07 14:27

Consider:

#include
using namespace std;

class Base
{
    public:
        virtual void show() { cout<<\" In Base \\n\"; }
};

class Der         


        
6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-07 14:42

    That could easily be resolved at compile time if the optimizer chose to do so.

    The standard specifies the same behavior as if the run-time polymorphism had occurred. It does not specific that be achieved through actual run-time polymorphism.

提交回复
热议问题