Quantcast
Channel: C++ friend functions/class uses? - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by juliomalegria for C++ friend functions/class uses?

$
0
0

Using friend is actually very discouraged in C++ (it kinda breaks the whole encapsulation idea), but it comes to my mind an example where only friend is the right approach:

friend ostream & operator<< (ostream & out, const MyClass & C);friend istream & operator>> (istream & in, MyClass & C);

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>