静态函数导致更多的静态函数 [英] Static function leading to more static functions
问题描述
我有一个类,它有一些对自己有用的函数,它们是静态的。现在这些函数依赖于其他对它们自己没有用的函数(但不与类成员变量交互),但也是静态的,因此它们是私有的。现在我有一个类有很多非静态函数,和几个静态公共函数和一些静态私有函数。
I have a class that has a few functions that are useful on their own, which are static. Now these functions depend on other functions that are not useful on their own (but don't interact with class member variables) but are also static, so they are private. Now I have a class with many non-static functions, and couple of static public functions and a few static private functions.
这是好的做法吗? (我应该是一个社区wiki吗?)
Is this good practice? (should I be making this a community wiki?)
推荐答案
我认为你应该声明这些函数为自由函数。如果他们不需要成员,这不应该是一个大问题。
也许您应该阅读此文章。我发现这对提高我的课堂设计非常有用。
I think you should declare those functions as free functions. If they do not need the members it should be not a big deal.
Maybe you should read this article. I found it very useful to improve my class designs.
这篇关于静态函数导致更多的静态函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!