C++: How to design a utility class?

后端 未结 5 433
你的背包
你的背包 2021-01-03 00:33

But I don\'t know if I should go for static methods, just a header, a class, or something else?

What would be best practice? But, I don\'t want to have an instance o

5条回答
  •  醉话见心
    2021-01-03 01:14

    There's probably no reason to have a class to wrap these functions if they don't logically belong to a class. In that case you can just have them be free functions. It might be appropriate to contain them in a namespace to help avoid name collisions.

    If you want to provide a stringer logical grouping of the classes, there's no real harm in having them be static member functions of a class - but I see no reason why you'd have functions like MapRGB() and CopyString() need to be members of the same class.

提交回复
热议问题