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

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

    1. Static data members always share the memory.
    2. only static function can used static data members.
    3. static member function can be called with class name.
    4. They must be defined outside of the class when we create a object of static member or member function in the class. It will automatically initialize the value.
    5. It always used keyword static.
    6. Static members can share by all the objects.
    7. Type and scope of data members and member function is outside of the class.
    8. A static member variable must be defined outside of the class.

提交回复
热议问题