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

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

    Here is what I think it is:

    Friend function- when you need access to a different class member, but the classes are not related. Static function- when you no not need access to the 'this' pointer. But, I have a feeling there is more to it....

提交回复
热议问题