struct A { virtual const char* fn() { return "A"; } };
struct B : public A { virtual const char* fn() { return "B"; } };
#include <iostream>
#include <cstring>
int main()
{
A* a = new A();
B* b = new B();
memcpy(a, b, sizeof(A));
std::cout << "sizeof A = " << sizeof(A)
<< " a->fn(): " << a->fn() << '\n';
}
ICAgIHN0cnVjdCBBIHsgdmlydHVhbCBjb25zdCBjaGFyKiBmbigpIHsgcmV0dXJuICJBIjsgfSB9OwogICAgc3RydWN0IEIgOiBwdWJsaWMgQSB7IHZpcnR1YWwgY29uc3QgY2hhciogZm4oKSB7IHJldHVybiAiQiI7IH0gfTsKCiAgICAjaW5jbHVkZSA8aW9zdHJlYW0+CiAgICAjaW5jbHVkZSA8Y3N0cmluZz4KICAgIAogICAgaW50IG1haW4oKQogICAgewogICAgICAgIEEqIGEgPSBuZXcgQSgpOwogICAgICAgIEIqIGIgPSBuZXcgQigpOwogICAgICAgIG1lbWNweShhLCBiLCBzaXplb2YoQSkpOwogICAgICAgIHN0ZDo6Y291dCA8PCAic2l6ZW9mIEEgPSAiIDw8IHNpemVvZihBKQogICAgICAgICAgICA8PCAiIGEtPmZuKCk6ICIgPDwgYS0+Zm4oKSA8PCAnXG4nOwogICAgfSAgICAgICAK