Клас в класі

Внутрішній клас використовується для потреб зовнішнього (всеохоплюючого), 

і може знаходитися в будь-якій секції public, private, protected

class Book {

 public:

     void GetDates() {

          for (int i = 0; i < 3; i++)

          {

               cout << "Book" << i << ": " << mas[i].GetDate() << endl;

          }

     }

 private:

     // приватний клас - тільки для зовнішнього класу

     class Date {

      public:

          Date(int d, int m, int y) {

               this->d = d;

               this->m = m;

               this->y = y;

          }

          string GetDate() {

               return to_string(d) + "." + to_string(m) + "." + to_string(y);

          }

      private:

          int y;

          int m;

          int d;

     };

     Date mas[3]{

          Date(1, 1, 2020),

          Date(1, 1, 2021),

          Date(1, 1, 2022)

     };

};

int main()

{

     Book b1;

     b1.GetDates();

     system("pause");

     return 0;

}

Book0: 1.1.2020

Book1: 1.1.2021

Book2: 1.1.2022

Якщо внутрішній клас перенести в public, то ми б могли мати доступ до нього

     Book::Date d1(1, 2, 2075);

     cout<<d1.GetDate();

1.2.2075