// 実行時型情報(RTTI)
// typeid演算子を使ってみる
// (*) RTTI : run-time type identification


#include <iostream>
#include <typeinfo>

using namespace std;

class foo {
	int  i;
	// ...
};


int
main( )
{
	char	c;
	char*	cp;
	int		i;
	float	f;
	foo		ob,*pob;

	cout << "type of   c: " << typeid( c ).name( ) << endl;
	cout << "type of  cp: " << typeid( cp ).name( ) << endl;
	cout << "type of   i: " << typeid( i ).name( ) << endl;
	cout << "type of   f: " << typeid( f ).name( ) << endl;
	cout << "type of  ob: " << typeid( ob ).name( ) << endl;
	cout << "type of pob: " << typeid( pob ).name( ) << endl;

	return 0;
}

/*
	RTTIは型を実行時に教えてくれるわけですが、
	今回の例は、実行以前に分かっています(^^;
	とりあえず、型名(厳密にはtype_info型のオブジェクトへの参照)
	を返してくれることが体験できました。
*/


// end of file