nested class

A nested class is a class that is defined within another class. 
Nested classes are divided into two categories: static and non-static. Nested classes that are declared static are called static nested classes. Non-static nested classes are called inner classes. 
Local inner class is a class defined in a class method. In some languages such as Java, it is a nested class; in other languages such as C++, it is a local class.
Although a nested class is defined in the scope of its enclosing class, it is important to understand that there is no connection between the objects of an enclosing class and objects of its nested class(es). A nested-type object contains only the members defined inside the nested class. Similarly, an object of the enclosing class has only those members that are defined.
In general, nested classes should be used sparingly. There are several reasons for this. Some developers are not fully familiar with the concept. These developers might, for example, have problems with the syntax of declaring variables of nested classes. Nested classes are also very tightly coupled with their enclosing classes, and as such are not suited to be general-purpose classes.
Nested classes are best suited for modeling implementation details of their enclosing classes. The end user should rarely have to declare variables of a nested class and almost never should have to explicitly instantiate nested classes. 
Nested class is a way of logically grouping classes that are only used in one place: If a class is useful to only one other class, then it is logical to embed it in that class and keep the two together. Nesting such "helper classes" makes their package more streamlined. Nested classes are cool for hiding implementation details. It increases encapsulation: Consider two top-level classes, A and B, where B needs access to members of A that would otherwise be declared private. By hiding class B within class A; A's members can be declared private and B can access them. In addition, B itself can be hidden from the outside world. It can lead to more readable and maintainable code: Nesting small classes within top-level classes places the code closer to where it is used. Below is a good example for this idea.
```
class List
{
public:
    List(): head(nullptr), tail(nullptr) {}
private:
    class Node
    {
      public:
          int   data;
          Node* next;
          Node* prev;
    };
private:
    Node*     head;
    Node*     tail;
};
```
Nested class in different programming languages:
* There is no nested class in JavaScript.
* There is no nested class in PHP.
* There is no nested class in TypeScript.