C++ child class using parent class function
<p>I got a bit of issue here.</p>

<ul>
<li>Vehicle is parent class</li>
<li>Car and Motorcycle is child class</li>
</ul>

<p>this is my main cpp file</p>

<pre><code>int main() {
    // assuming max size is up to 100
    VehicleTwoD *vehicletwod[100];
    int vehicleCounter = 0;

    Car *car = new Car();
    Motorcycle *motor = new Motorcycle();

    cout &lt;&lt; " Please enter name of vehicle ";
    cin &gt;&gt; vehicleName;

    if (vehicleName == "Car") {
        vehicletwod[vehicleCounter] = car;

        //issue here
        vehicletwod[vehicleCounter].setName(vehicleName);
        //issue end

    }

    return 0;
}
</code></pre>

<p>This is my car.cpp</p>

<pre><code>struct Point {
    int x, y;
};

class Car: public Vehicle {
private:
    Point wPoint[4];
    double area;
    double perimter;
public:
    void setType(string);
    void setPoint();
    string getType();
    string getPoint();
}
</code></pre>

<p>The issue here is setName is a function of Vehicle, but not a function of Car. but i did the inheritance which should inherit the function. but doesn't seems to work.</p>

<p>It say...Request for setName in vehicletwod[vehicleCounter]' which is of non class type VehicleTwoD*</p>

<p><strong>Above Issue is fixed</strong> </p>

<p>Additional Issue:</p>

<p>Okay i fixed the previous issue by changing . to -></p>

<p>Here the other issue.</p>

<p>as the code is. on this part</p>

<pre><code> if (vehicleName == "Car") {
            vehicletwod[vehicleCounter] = car;

            vehicletwod[vehicleCounter]-&gt;setName(vehicleName);


           //now i want to setPoint which is a function of child class
           vehicletwod[vehicleCounter]-&gt;setPoint();
           //issue here
        }
</code></pre>

<p>I try  to setPoint which is a function of child class, Car</p>

<p>However it say.. Vehicle has no member named 'setPoint'</p>

<p><strong>After doing what John mention.. the above issue is also fixed..</strong></p>

<p>But the hardest part is on how to retrieve what been set since it is a vehicletwod object and not a car object.</p>

<p>Assume after setPoint, i want to getPoint() </p>

<p>i try do this</p>

<p>vehicletwod[0]->getPoint();</p>

<p>I get an error saying getPoint is of non-class type 'vehicletwod'</p>
