C++ accessing object method through array of pointers to objects
<p>I have trouble figuring out how to access bject method through array of pointers to objects.</p>

<p>I have an <strong>env</strong> object of Environment class:</p>

<pre><code>Environment env;
</code></pre>

<p>My Environment has some object pointers as well as a dynamic array of pointers:</p>

<pre><code>    static Robot *robot;
    static Obstacle *obstacle;
    static Object **objects;
</code></pre>

<p>So inside <strong>objects</strong> I can have robots and obstacles:</p>

<p>But now when I want to access a method of an object in the <strong>objects</strong> array, how can I do that? I tried</p>

<pre><code>    Environment env;
    Robot *robot;

    robot = env.objects[0];
    robot-&gt;setSpeed(175);
</code></pre>

<p>But it didn't work. I got an error:</p>

<pre><code>error: invalid conversion from ‘Object*’ to ‘Robot*’
</code></pre>

<p>What am I doing wrong?</p>

<p><strong>PS: Robot inherits from Object.</strong></p>

<p>Thank you in advance!</p>
