#include <iostream>
#include <string>

using namespace std;

struct NO_INIT {};

class Thing {
	int a;
public:
    Thing(int v = 0): a (v) {}
    Thing(NO_INIT) {} 
	virtual const char * type_name(){ return "Thing"; }
	virtual int value() { return a; }
};

class OtherThing : public Thing {
public:
	OtherThing(int v): Thing(v) {}
	OtherThing(NO_INIT ni): Thing(ni) {}
	
	virtual const char * type_name() { return "Other Thing"; }
};

template <typename TO_T>
inline TO_T* turn_thing_to(Thing* p) 
{
  return ::new(p) TO_T(NO_INIT()); 
}

int main() {
	Thing * thing = new Thing(42);
	std::cout << thing->type_name() << "\n";
	std::cout << thing->value() << "\n";
	
	turn_thing_to<OtherThing>(thing);
	std::cout << thing->type_name() << "\n";
	std::cout << thing->value() << "\n";
	return 0;
}