In C++, "dynamic\_cast" being slow is a known fact. I thought of following simple way of knowing the type of an object in a hierarchy. Could someone please explain if this could be slower than dynamic\_cast? And if not, then why isn't it a common practice, given that speed is the worst drawback of C++ over C?

```
struct Base {
  unsigned m_type;
  Base(unsigned type): m_type(type) {}
  Base(): m_type(0) {}
};
struct Derived1: Base {
  Derived1(): Base(1) {}
  Derived1(int type): Base(type) {}
};
struct Derived2: Base {
  Derived2(): Base(2) {}
};
struct Derived3: Derived1 {
  Derived3(): Derived1(3) {}
};
void my_func(Base * p) {
  if (p - > m_type == 0) {} 
  else if (p - > m_type == 1) {} 
  else if (p - > m_type == 2) {} 
  else if (p - > m_type == 3) {}
}

```