Static member functions

后端 未结 5 1301
自闭症患者
自闭症患者 2020-12-08 16:30

After reading sbi and Eli Bendersky\'s answers in this question I started to wondering what static member functions are for.

A class\' friend free function shouldn\'

5条回答
  •  情书的邮戳
    2020-12-08 17:17

    Some people are wary of using static functions because it's often used by those who come from a procedural background and don't understand OO.

    However there are many design patterns that make sense to be implemented using static member functions

    For example. Singleton and Factory patterns to name a couple of the top my head, in fact most structural patterns that require object creation would require static member functions.

提交回复
热议问题