And, when deciding on which ship salutes which as they pass, is the decision based purely on the Captain's seniority or is there a pecking order in class of ship as well?
To amplify Alfred's response to Wrathmonk's question, the presence of a senior officer on board a warship, provided he is flying either his flag, or his broad pendant in the case of a Commodore, will obviously trump the seniority of the commanding officer in terms of compliments being paid by other ships. Responsibility for the flagship, or senior ship in the case of a Commodore, remains with the Flag Captain or commanding officer respectively, but it is a wise man who keeps his senior officer informed of his intentions where and when it is appropriate. Curiously enough, when a flagship, or senior ship, sails is one of the few occasions when a senior officer calls a junior officer "Sir", as in the example "Will you get the flagship under way, Sir".
Taking up PN's PS, I recall one patrol submarine in which every one of the officers was a Lieutenant, from the Captain to the Fifth Hand, but there was no doubt who was the Boss ....