title: What is best way to know type of sender object?
body: <p>I have hierarchy of classes:</p>
  
  <pre><code>class A
  {
  };
  
  class B : public A
  {
  };
  
  class C : public B
  {
  };
  
  class D : public A
  {
  };
  </code></pre>
  
  <p>and I have some function, which performs notification:</p>
  
  <pre><code>void notify(A* sender, const NotificationType notification)
  {
  }
  </code></pre>
  
  <p>My problem is how to find out exact type of sender object. I want to find elegant way to solve this problem. I don't like to use dynamic cast for these purposes. Possible way is to define enum within class A like:</p>
  
  <pre><code>enum ClassType
  {
      CLASS_A,
      CLASS_B,
      CLASS_C,
      CLASS_D
  };
  </code></pre>
  
  <p>and defining virtual method:</p>
  
  <pre><code>virtual ClassType get_type(void) const;
  </code></pre>
  
  <p>But this approach has bad scalability. Another way to keep this information in NotificationType, but it has bad scalability too.</p>
  
  <p>P.S. I just want to use similar code:</p>
  
  <p>I want to use similar code:</p>
  
  <pre><code>void notify(A* sender, const NotificationType notification)
  {
      if (sender is object of A)
         new GuiA();
      else if (sender is object of B)
         new GuiB();
      else if (sender is object of C)
         new GuiC();
      else 
         new GuiD();
  }
  </code></pre>