R
Ravi
using namespace std;
#include <iostream>
#include <typeinfo>
class Vehichle {
public:
int i1;
};
class Car: public Vehichle {
public:
int i2;
};
int main()
{
Car c;
Vehichle *v = &c;
cout << typeid(*v).name() << endl; // <--- should output car
cout << typeid(c).name() << endl;
cout << (typeid(*v) == typeid(c)) << endl; // <--- should output
1
return 0;
}
code also at http://pastebin.com/f6928ebd1
I am learning C++. In the above code I am getting the the putput
Vehichle and 0 for the respective arrows. The book says different. Can
you please explain why?
#include <iostream>
#include <typeinfo>
class Vehichle {
public:
int i1;
};
class Car: public Vehichle {
public:
int i2;
};
int main()
{
Car c;
Vehichle *v = &c;
cout << typeid(*v).name() << endl; // <--- should output car
cout << typeid(c).name() << endl;
cout << (typeid(*v) == typeid(c)) << endl; // <--- should output
1
return 0;
}
code also at http://pastebin.com/f6928ebd1
I am learning C++. In the above code I am getting the the putput
Vehichle and 0 for the respective arrows. The book says different. Can
you please explain why?