// Example 3-7: Using typeid.
#include <iostream>
#include <ostream>
#include <typeinfo>

class base {
public:
  virtual ~base() {}
};

class derived : public base {};
enum color   { red, black };

// The actual output is implementation-defined, but should
// reflect the types shown in the comments.
int main()
{
  base* b = new derived;
  std::cout << typeid(*b).name() << '\n';      // derived
  std::cout << typeid(base).name() << '\n';    // base
  derived* d = new derived;
  std::cout << typeid(*d).name() << '\n';      // derived
  std::cout << typeid(derived).name() << '\n'; // derived
  std::cout << typeid(red).name() << '\n';     // color
  std::cout << typeid(color).name() << '\n';   // color
}
