Reputation: 1721
Hey im coming from a java background, im reading a c++ book and it says that typeid() returns an object of type_info. But if i try to do something like;
type_info *x = typeid(somthing);
I get the error : no suitable conversion from const type_info to type_info exists.
Can someone tell me how i can get a reference to a type_info object?
Upvotes: 1
Views: 116
Reputation: 21900
The typeid
operator returns a const type_info&
. Therefore, you need a const reference, not a pointer:
const std::type_info &x = typeid(something);
Upvotes: 4