#include <iostream>
using namespace std;
class Base
{
public:
virtual void print(){cout<<"Base virtual"<<endl;}
void nonvirt_print(){cout<<"Base"<<endl;}
};
class Derived : public Base
{
public:
virtual void print() override {cout<<"Derived virtual"<<endl;}
void nonvirt_print(){cout<<"Derived"<<endl;}
};
int main() {
Derived *derived_arr[100];
for(int i=0;i<100;++i)
derived_arr[i] = new Derived();
Base *base_arr[100];
for(int i=0;i<100;++i)
base_arr[i]=derived_arr[i];
base_arr[10]->nonvirt_print(); //base
base_arr[10]->print(); //derived virtual
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgQmFzZQp7CglwdWJsaWM6Cgl2aXJ0dWFsIHZvaWQgcHJpbnQoKXtjb3V0PDwiQmFzZSB2aXJ0dWFsIjw8ZW5kbDt9Cgl2b2lkIG5vbnZpcnRfcHJpbnQoKXtjb3V0PDwiQmFzZSI8PGVuZGw7fQp9OwoKY2xhc3MgRGVyaXZlZCA6IHB1YmxpYyBCYXNlCnsKCXB1YmxpYzoKCXZpcnR1YWwgdm9pZCBwcmludCgpIG92ZXJyaWRlIHtjb3V0PDwiRGVyaXZlZCB2aXJ0dWFsIjw8ZW5kbDt9IAoJdm9pZCBub252aXJ0X3ByaW50KCl7Y291dDw8IkRlcml2ZWQiPDxlbmRsO30KfTsKCmludCBtYWluKCkgewoJRGVyaXZlZCAqZGVyaXZlZF9hcnJbMTAwXTsKCWZvcihpbnQgaT0wO2k8MTAwOysraSkKCQlkZXJpdmVkX2FycltpXSA9IG5ldyBEZXJpdmVkKCk7CglCYXNlICpiYXNlX2FyclsxMDBdOwoJZm9yKGludCBpPTA7aTwxMDA7KytpKQoJCWJhc2VfYXJyW2ldPWRlcml2ZWRfYXJyW2ldOwoJYmFzZV9hcnJbMTBdLT5ub252aXJ0X3ByaW50KCk7IC8vYmFzZQoJYmFzZV9hcnJbMTBdLT5wcmludCgpOyAvL2Rlcml2ZWQgdmlydHVhbAoJcmV0dXJuIDA7Cn0=