Wednesday, 23 January 2019

What is a local class and why can it be useful

What is a local class? Why can it be useful?

Answer:

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.

No comments:

Post a Comment