For example, I've overloaded `operator<<` in two different ways:

`ofstream & operator<<(ofstream & fout, const Thing & t);`

`ostream & operator<<(ostream & out, const Thing & t);`

I've done this because I want the output to a file to be different than the output to console. As far as I am aware, `ofstream` is derived from `ostream`, so how does the compiler know to pick the overloaded operator with `ofstream` rather than just picking the one with `ostream` when I do something like

```
ofstream fout("file.txt")
fout.open();
Thing t;
fout << t;

```

Because even without the overloaded operator with `ofstream`, that code will still work with the `ostream` one.