Search

The Online Encyclopedia and Dictionary

 
     
 

Encyclopedia

Dictionary

Quotes

 

Nested function

A nested function is a function which can only be called from its parent function. That is, the scope of the nested function is limited to the current function only. For instance, assuming that C supports nested functions (which it does not):

void foo() {
 void bar() {
  /* do something */
 };
 bar();
}

In this case bar is a nested function for foo and can only be called from foo.

Nested functions are useful for creating code blocks that must remain logically separate but are only useful for a specific function as opposed to the entire module or program.

The contents of this article are licensed from Wikipedia.org under the GNU Free Documentation License. How to see transparent copy