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

后端 未结 15 2239
[愿得一人]
[愿得一人] 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:26

    A static function is a function that does not have access to this.

    A friend function is a function that can access private members of the class.

提交回复
热议问题