What is a local class? Why can it be useful?
Local class is a class defined within the scope of a function — any function, whether a member function or a free function. For example:
// Example 2: Local class
//
int f()
{
class LocalClass
{
// …
};
// …
};
Like nested classes, local classes can be a useful tool for managing code dependencies.
Explore posts in the same categories: C/C++ Interview Questions