When you implement
<<
and >>
for your class, they accept a reference to the stream base class. How else could that work? (Yes, there are some possible alternative designs, but inheritance seems natural here.)