Where would you use a friend function vs. a static member function?

后端 未结 15 2233
[愿得一人]
[愿得一人] 2020-12-02 04:56

We make a non-member function a friend of a class when we want it to access that class\'s private members. This gives it the same access rights as a static member function w

15条回答
  •  死守一世寂寞
    2020-12-02 05:31

    A friend function can not be inherited while a static function can be. So when an aim can be achieved with both static function and friend function, think that whether you want to inherit it or not.

提交回复
热议问题