I don't know how can a function of a class use private member declared in another class?!
An example of where it is very useful is when overloading operators for which your class is on the right. Example:
1 2 3 4 5 6 7 8 9 10
|
class Foo
{
int bar;
friend std::ostream& operator<<(std::ostream&, Foo&);
};
std::ostream& operator<<(std::ostream& o, Foo& f)
{
return o<<f.bar;
}
|
Last edited on