Код: Выделить всё
struct Base
{
virtual int transmogrify();
};
struct Derived : Base
{
int transmogrify() override
{
// missing this->~Derived();?
new(this) Base;
return 2;
}
};
int Base::transmogrify()
{
// missing this->~Base();?
new(this) Derived;
return 1;
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... cement-new