Is there reason to create class for single function?

Classes are not just "function containers", they are there to represent an object, an entity. They are supposed to encapsulate the data required for the given entity with methods that work for it.

Sometimes there might be a class of object that only needs one method defined for it, but nevertheless it only belongs to that class of object.


I mostly do embedded programming, and seldom use classes. But a single function class could possibly be used to -

  • inherited later
  • enforce integrity of the data structure that is private to the class (encapsulation).
  • may be used to maintain the homogeneity of the code.