 <p>What you're talking about is called a <a href="http://en.wikipedia.org/wiki/Callback_%28computer_science%29" rel="nofollow noreferrer">callback</a> and is implemented with <a href="http://www.newty.de/fpt/index.html" rel="nofollow noreferrer">function pointers</a> in C and C++.</p> <p>Since you mentioned glut, let's take a real example directly from the <a href="http://freeglut.sourceforge.net/" rel="nofollow noreferrer">freeglut</a> source code. I'll use <a href="http://freeglut.sourceforge.net/docs/api.php#GlobalCallback" rel="nofollow noreferrer">glutIdleFunc</a> instead of glutTimerFunc because the code is simpler.</p> <p>In glut, the idle function callback (what you supply to glutIdleFunc) is a pointer to a function that takes no parameters and returns nothing. A typedef is used to give such a function type a name:</p> <pre><code>typedef void (* FGCBIdle)( void ); </code></pre> <p>Here, FGCBIdle (short for FreeGlut CallBack Idle) is defined as a pointer to a function that takes no parameters and whose return type is void. This is just a type definition that makes writing expression easier, it doesn't allocate any storage.</p> <p>Freeglut has a structure called SFG_State that holds various settings. Part of the definition of that structure is:</p> <pre><code>struct tagSFG_State { /* stuff */ FGCBIdle IdleCallback; /* The global idle callback */ /* stuff */ }; </code></pre> <p>The struct holds a variable of type FGCBIdle, which we established is another name for a specific function pointer. You can set the IdleCallback field to point to the address of a function that is supplied by the user using the glutIdleFunc function. The (simplified) definition of that function is:</p> <pre><code>void glutIdleFunc( void (* callback)( void ) ) { fgState.IdleCallback = callback; } </code></pre> <p>Here, fgState is a SFG_State variable. As you can see, the glutIdleFunc takes one parameter which is a function pointer to a function that takes no parameters and returns nothing, this parameter's name is callback. Inside the function, the IdleCallback inside the global fgState variable is set to the user supplied callback. When you call the glutIdleFunc function, you pass the name of your own function (e.g. glutIdleFunc(myIdle)), but what you're really passing is the address of the function.</p> <p>Later, inside the big glut event processing loop initiated by glutMainLoop, you'll find this code:</p> <pre><code>if( fgState.IdleCallback ) { /* stuff */ fgState.IdleCallback( ); } </code></pre> <p>If a user supplied idle callback is available, it is called in the loop. If you check the function pointer tutorial at the beginning of my post you will understand the syntax better, but I hope the general concept makes more sense now. </p>