C++ How to access an object initialized in main() from outside of main()?
<p>My main() looks like this:</p>

<pre><code>   int main(int argc, char** argv)
    {
    // Initialize GLUT
    glutInit(&amp;argc, argv);

    ...

    glutDisplayFunc(display);
    ...

    // Set robot's parameters
    Robot robot; // Initialize global object robot
    robot.setSize(50);
    robot.setColor('G');
    robot.setLocation(50,100);

    glutMainLoop();
    return EXIT_SUCCESS;
}
</code></pre>

<p>Then I have another function, which I would like to have access to the methods of the robot:</p>

<pre><code>// This function is constantly "looped"
void display() {
    ...
    robot.draw();
    ...
}
</code></pre>

<p>What is the legit way to do it in C++?</p>
