dimanche 3 février 2019

what does compiler when operator<<(std::basic_ostream) overloaded as friend [duplicate]

This question already has an answer here:

declaration in class:

friend ostream& operator<<(ostream & os, const MyClass & _my_class );

call:

MyClass mc;
...
...
cout << mc << endl;

  1. Why does something like that not work?

    cout.operator<<(mc)

  2. Where is the first argument?

    (ostream &os, ...)

  3. How does compiler solve this?

Aucun commentaire:

Enregistrer un commentaire