typeid 関数を正しく取得できません。何か足りない?
コード:
class A
{
public:
int a1;
A()
{
}
};
class B: public A
{
public:
int b1;
B()
{
}
};
int main()
{
B tempb;
A tempa;
A * ptempa;
ptempa = &tempb;
std::cout << typeid(tempb).name() << std::endl;
std::cout << typeid(tempa).name() << std::endl;
std::cout << typeid(*ptempa).name() << std::endl;
return 0;
}
常に出力されます:
B級 A級 A級
プロジェクトにVS2010を使用しています