As for cadets, I couldn't find any real world precedence but I always think of "Starship Troopers" when it is discussed. The section is too long to write out, but the basic concept is that cadets may receive promotions (in the book to third lieutenant) at the end of their course of instruction, which puts them in the chain of command. So, I imagine that cadets can be field promoted if the situation warrants it.
In the US Navy, anyway, midshipmen have official precedence sandwiched in between grade W-1 (warrant) and W-2 (commissioned warrant). In practice this doesn't really matter because the only times they are in contact with real units, summer cruises and such, the the petty officers have authority over them as instructors. A midshipman who tries to throw his "rank" around with a senior petty officer is headed for a come-uppance he will surely regret.
In the 20th century, in the US at least, officer training became heavily academic, with commissions being granted along with the college degree. The thing in Starship Troopers is a throwback to earlier times, when commissions were only granted after a probationary period of on-the-job training and actual service in operating units. Until 1912 (only 17 years before Heinlein graduated) midshipmen graduating from the US Naval Academy had to then serve two years in the fleet before being commissioned as ensigns. This was partly left over from the days when the only way to get a commission was "apprenticeship" at sea, and partly a reflection of the fact that being an officer at sea, especially in the sailing navy, required a complex skill set that could only really be acquired by first-hand experience; graduates going into the Marines were commissioned 2nd lieutenants immediately.