/*Orion Lawlor's Simple C++ Examples, olawlor@acm.org
Shows how to use run-time type information.
*/
#include <iostream>
#include <complex>
#include <typeinfo>

class parent {
public:
	virtual void fn(void) {}
};
class child1:public parent { };
class child2:public parent { };
class child3:public child2 { };

template <class T>
void typeInfo(const T& t)
{
	std::cout<<typeid(t).name()<<std::endl;
}

void parentInfo(parent *p)
{
	std::cout<<typeid(p).name()<<" -> "<<
		typeid(*p).name()<<std::endl;
	delete p;
}

int main()
{
	typeInfo((short)1);
	typeInfo(1);
	typeInfo((long)1);
	typeInfo(1.0);
	typeInfo(std::complex<float>(2.3,4.6));
	parentInfo(new parent);
	parentInfo(new child1);
	parentInfo(new child2);
	parentInfo(new child3);
	
	return 0;
}
/*<@>
<@> ******** Program output: ********
<@> s
<@> i
<@> l
<@> d
<@> St7complexIfE
<@> P6parent -> 6parent
<@> P6parent -> 6child1
<@> P6parent -> 6child2
<@> P6parent -> 6child3
<@> */
