There are many different flights made by airlines. Time of flights and destinations of flights are different. Some flights take 2-3 hours and some flights have been taking 14-15 hours.
Ranges of aircrafts are distnict from each other.(Range depends on weight of aircraft ,fuel capacity, size of aircraft and such)
A330,B777,B787,B747,A380 like aircrafts are long-range aircrafts. Airlines use these aircrafts in the 14-15 hours flights.
The flight crews and cabin crews on these longtime flights need to rest in the certain times.
Therefore long-range aircrafts are equipped with hidden rest rooms for resting of flight crews and cabin crews. The person can rest in these rooms by following rules during straight cruise phase of flight. So pilots sleep during flight in this way.
For instance;
There are 2 rest rooms for flight and cabin crew in the B777. Flight crew rest rooms are located begining of front passenger compartment. Cabin crew rest rooms are located end and upstair of aft passenger compartment (Person can access with ladder). Passengers cannot access to these rooms. Because both doors have locks and doors are hidden.
These rooms are rather modest and narrow. There are bunk beds and various service equipment in the rest rooms.
Another example;
Rest rooms are located below of passenger compartment in the A330-A340 aircrafts. Crews can access to rest room with secret door on the ground.
So pilots and flight attendants can sleep during flights…
https://aircrafttechnic.com/