Sign in to follow this  
Hermes

RTTI

Recommended Posts

Hi i have the following piece of code .I made it very simple:
#include "stdafx.h"
#include<typeinfo.h>
#include<iostream>
using namespace std;

class A1
{
	virtual ~A1(){}
};
class A2:public A1 
{


};
class A3:public A2
{

};
int main(int argc, char* argv[])
{

A1* derived=new A3;	

try
{
A3* cast=dynamic_cast<A3*>(derived);
cout<<typeid(cast).name<<endl;	
}
catch(bad_cast)
{
cout<<"\n This was  a bad cast"<<endl;
}

	
	return 0;
}




My question is :Why the typeid info returns 1 instead of an info like A3* Thanks a lot

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this