Base and child class function inheritance confusion (C++)
<p>I am very confused about base and child class function inheritance.
I have those classes:</p>

<pre><code>#include &lt;point.h&gt;

class Polygon{
public:
    Polygon();
    virtual ~Polygon();
    void addPoint(Point *p);
    std::string getType();
    Point* getPoint(int index);
    int getNumOfPoints();
    int getColor();
    virtual int area()=0;

private:
  std::vector&lt;Point*&gt; _points;

  int color;
  std::string type = "Polygon";

};

class Rectangle : public Polygon{
public:
    Rectangle();
    virtual ~Rectangle();
    virtual int area();

private:
    std::vector&lt;Point*&gt; _points;

    int color;
    std::string type = "Rectangle";
};
</code></pre>

<p>Now, in the main I do this:</p>

<pre><code>Rectangle rect();
rect.getType();
</code></pre>

<p>this gives me "Polygon" while I want "Rectangle"
I am quite sure I am confused with inheritance. So, according to how I understand, the base class functions get inherited, but why is it when I run the function it relates to the members of the object base class but not the actual object (Rectangle)?</p>

<p>Will be happy if someone would help!
Much appreciated</p>
