Sign in to follow this  

RTTI

This topic is 4779 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

This topic is 4779 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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