December 2001
Intermediate to advanced
304 pages
6h 25m
English
Difficulty: 5
C++ has nested classes, but not nested functions. When might nested functions be useful, and can they be simulated in C++?
What is a nested class? Why can it be useful?
What is a local class? Why can it be useful?
C++ does not support nested functions. That is, we cannot write something like
// Example 33-3
//
int f( int i )
{
int j = i*2;
int g( int k ) // not valid C++
{
return j+k;
}
j += 4;
return g( 3 );
}
Demonstrate how it is possible to achieve the same effect in standard C++, and show how to generalize the solution.
C++ provides many useful tools for ...
Read now
Unlock full access