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();
*a = *b; // aka a->operator=(static_cast<A*>(*b));
std::cout << "sizeof A = " << sizeof(A)
<< " a->fn(): " << a->fn() << '\n';
}
ICAgIHN0cnVjdCBBIHsgdmlydHVhbCBjb25zdCBjaGFyKiBmbigpIHsgcmV0dXJuICJBIjsgfSB9OwogICAgc3RydWN0IEIgOiBwdWJsaWMgQSB7IHZpcnR1YWwgY29uc3QgY2hhciogZm4oKSB7IHJldHVybiAiQiI7IH0gfTsKCiAgICAjaW5jbHVkZSA8aW9zdHJlYW0+CiAgICAjaW5jbHVkZSA8Y3N0cmluZz4KICAgIAogICAgaW50IG1haW4oKQogICAgewogICAgICAgIEEqIGEgPSBuZXcgQSgpOwogICAgICAgIEIqIGIgPSBuZXcgQigpOwogICAgICAgICphID0gKmI7IC8vIGFrYSBhLT5vcGVyYXRvcj0oc3RhdGljX2Nhc3Q8QSo+KCpiKSk7CiAgICAgICAgc3RkOjpjb3V0IDw8ICJzaXplb2YgQSA9ICIgPDwgc2l6ZW9mKEEpCiAgICAgICAgICAgIDw8ICIgYS0+Zm4oKTogIiA8PCBhLT5mbigpIDw8ICdcbic7CiAgICB9ICAgICAgIAo=