#include <iostream>

struct Base
{
    virtual ~Base(){}
    virtual void Print() const
    {
        std::cout << "Base" << std::endl;
    }
};

struct Derived : Base
{
    virtual ~Derived(){}
    virtual void Print() const
    {
        std::cout << "Derived" << std::endl;
    }
};

int main()
{
    Base *r1 = new Base;
    Base *r2 = new Derived;

    r1->Print();
    r2->Print();

    r1->~Base();
    r2->~Base();
    new ((void*)r1) Derived;
    new ((void*)r2) Base;

    r1->Print();
    r2->Print();
    
    delete r1;
    delete r2;
}
