#include <iostream>
#include <typeinfo>
using namespace std;

template<typename T>
class A
{
	public: T x;
	virtual void v(){};
};


int main() {
	
	A<int> a1;
	A<float> a2;
	cout<<typeid(a1).name()<<endl;
	cout<<typeid(a2).name()<<endl;
	void * pv = static_cast<void*>(&a2);
	A<int> * pai = static_cast<A<int>*>(pv);
	
	cout<<typeid(pai).name()<<endl; //pointer to A<int>
	cout<<typeid(*pai).name()<<endl; //A<float>!
	A<float> *dynamic = dynamic_cast<A<float>*>(pai); //funny, donno what happens here
	if(dynamic != nullptr) {
		cout<<typeid(*dynamic).name()<<endl;
	} else {
		cout<<"dynamic_cast failed!"<<endl;
	}
	return 0;
}