If the only functionality you need is do_something()
, without any other fields in the class, then the best way, IMO, is not having classes at all. simply define
void do_something() {...}
And it will be easier to call, just do_something()
and that's that.
If the function needs to operate on memeber variables of the class, then it should be a normal member function, in which case you call it from an instance:
ABC a;
a.do_something()
Static methods, on the other hand, are a means of making your code more organized, in the specific case when you have a full functioning class with members variables and member functions that work on them, but you also want one or more functions that don't relate to an instance specific variables states at all, but relate to the class in a logical way. That is, functions you could just as well write without being attached to a class at all.
For example, if you need a function that creates a specific instance of your class, like using a specific combination of constructor arguments, which would otherwise be to cumbersome to call each time, you could write it as a stand alone function, that creates and returns an instance of the class by calling the constructor with the arguments combination. But it's more resonable to explicitely relate it to the class. In this case, you can make it a static member function.