1

I have some function that are utility function and they are placed inside the namespace as functions.

Having some experience in C#, I know it is not possible to create such function and you need collect all of them inside a class and define them as static.

is it a good idea to do the same here? Creating a class and put all related functions static method of such class? Is there any speed difference?

saw that thread, but there is a big mistake on that answer: I am using classes that has static methods and no other type of method or state. So there is no chance that a static method uses internal data of the class.

All modern OO language such as C# and java doesn't allow you to put a method on a namespace by itself, so there should be a good reason for it. I think the reason is clear: in an OO system, we have class, no function.

C++ born from C and hence we can create functions inside the namespace, but we Should Not Do That!

mans
  • 17,104
  • 45
  • 172
  • 321

1 Answers1

1

There is no speed difference at all. In general, in C++ your current solution is a considered a better coding practice. See for instance this thread for more details: Namespace + functions versus static methods on a class

Community
  • 1
  • 1
Nemanja Trifunovic
  • 24,346
  • 3
  • 50
  • 88
  • 1
    I saw that thread, but there is a big mistake on that answer: I am using classes that has static methods and no other type of method or state. So there is no chance that a static method uses internal data of the class. – mans Jan 29 '15 at 15:40