-1

You can inject a friend declaration into a namespace by declaring it within an enclosed class:

namespace Me {
class Us {
friend void you();
};
}

Now the function you( ) is a member of the namespace Me. If you introduce a friend within a class in the global namespace, the friend is injected globally.

Can someone explain with an example what is meaning of above lines.

Maddyfire
  • 61
  • 5

1 Answers1

1

You can inject a friend declaration into a namespace by declaring it within an enclosed class:

namespace Me {
class Us {
friend void you();
};
}

Now the function you( ) is a member of the namespace Me. If you introduce a friend within a class in the global namespace, the friend is injected globally.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055