If I am just deplaning a commercial flight and I see the captain (4 bars on the epaulet) and want to thank him/her for a safe and enjoyable flight, I would say "Excuse me, Captain, thanks for the nice flight".
However, if I were to encounter the first officer (3 bars), how should I address him or her? "Excuse me, First Officer...?"
Presumably not "Hey co-pilot!" :)