title: C++ polymorphism: Checking data type of sub class
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/351845/finding-the-type-of-an-object-in-c">Finding the type of an object in C++</a>  </p>
  </blockquote>
  
  
  
  <p>Hello,<br>
  I am sorry if it's a duplicate but I was not able to find answer to my question here.<br>
  Let's assume we have following class structure in c++:</p>
  
  <pre><code>class CPolygon {
    protected:
      int width, height;
    public:
      void set_values (int a, int b)
        { width=a; height=b; }
    };
  
  class CRectangle: public CPolygon {
    public:
      int area ()
        { return (width * height); }
    };
  </code></pre>
  
  <p>Now I have got a pointer to CPolygon object. How do I check if it's actually a pointer to the object of class CRectangle?</p>