A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
C/C++ does not allow methods to be defined inside another method. but C++ has support for lambda, which are used to define anonymous functions with closure. you can declare a variable and define as a lambda inside a method.
note: like fortran, C/C++ does not support calling a method that was not defined earlier in the source file. to get around this you use a forward declaration (function prototype). so the sample code could be written:
void initWindow(int* argc, char** argv);
void display(void);
int main(int argc, char** argv)
{
initWindow(&argc, argv);
glutMainLoop();
return 0;
}
void initWindow(int* argc, char** argv)
{
glutInit(argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH);
glutInitWindowPosition(100, 200);
glutInitWindowSize(800, 700);
glutCreateWindow("This is a window title");
glutDisplayFunc(display);
glutIdleFunc(display);
}
void display(void)
{
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glFlush();
}