namespace std {
class type_info
{
public:
virtual ~type_info(); //type_info can serve as a base class
// enable comparison
bool operator==(const type_info& rhs ) const;
// return !( *this == rhs)
bool operator!=(const type_info& rhs ) const;
bool before(const type_info& rhs ) const; // ordering
//return a C-string containing the type's name
const char* name() const;
private:
//objects of this type cannot be copied
type_info(const type_info& rhs );
type_info& operator=(const type_info& rhs);
}; //type_info
}
In the declaration of type_info class ,I can’t find any data member .So what is constructed or destructed ?? Also typeid isn’t declared in it.So how type_info object is accessed by it?
Is above representation incomplete? Please tell about the type of data member in type_info class
It looks like you are looking at the public interface of
typeinfofrom C++03. The standard doesn’t restrict an implementation from adding members to a standard class (so long as there names come from those reserved to the implementation) to make things work.In the implementation that I am currently using
std::typeinfohas a private memberconst char* __namewhich is used to implement the public member functions according to the requirements of the standard.ISO/IEC 14882:2011 17.5.2.3 Private members [objects.within.classes] / 1:
Similar wording appears in C++03 17.3.2.3.