












































#include <iostream>
#include <typeinfo.h>
class Base {
public:
virtual void vvfunc() {}
};
class Derived : public Base {};
using namespace std;
int main()
{
Derived* pd = new Derived;
Base* pb = pd;
cout << typeid( pb ).name() << endl; //prints "class Base *"
cout << typeid( *pb ).name() << endl; //prints "class Derived"
cout << typeid( *pd ).name() << endl; //prints "class Derived"
cout << typeid( pd ).name() << endl; //prints "class Derived *"
delete pd;
}
#include <iostream>
#include <typeinfo>
using namespace std;
class Test
{
public:
virtual ~Test()
{
}
virtual void Out()
{
cout<<typeid(*this).name()<<endl;
}
Test()
{
cout<<typeid(*this).name()<<endl;
}
};
class FromTest : public Test
{
public:
FromTest(){}
};
void main()
{
// void * v=new Test;
// Test * t=static_cast<Test *>(v);
Test * t=(Test *)(v);
// cout<<typeid(t).name()<<endl;
// t->Out();
// int i;
// cout<<typeid(i).name()<<endl;
FromTest ft;
Test * t;//=new FromTest;
Test l;
l.Out();
t=&ft;
cout<<typeid(*t).name()<<endl;
}
------------------------------------------------------------
<script type="text/javascript"> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>