ifstream
is inherited from istream
. Thus, we can use objects of type ifstream
as if they were istream
objects. The parameter of read
function is a reference to base type istream
, the automatic derived-to-base conversion applies when we pass a derived type ifstream
to that function. Inside read
function, we can use the istream
subpart in the ifstream
object through the reference.