C ++ is a language with several paradigms, where OO, procedural, general / generative and - smaller (but increasing with C ++ 0x) extensional functionality - are among the paradigms. You should use what works best for the problem: you want the code to be easy to get and keep in order, and hard to fill.
The usefulness of classes lies in the packaging of data (state) along with related functions. If your wordify function wordify not need to maintain any state between calls, then there is no need to use a class / object. However, if you can predict that you will soon want to have a state, then it may be useful to start with a class so that the client code does not need to be changed.
For example, imagine adding a parameter to a function to indicate whether the output should be "first", "second", and not "one", "two." You want the behavior to be set once and be remembered, but in another place of the application, different code can also use functionality, but prefers a different setting. It is a good idea to use an object to store state and organize it so that every object of life and accessibility is aligned with the code that will use it.
EDIT:
In the context of this question, where is the border between C and C ++ (if any)?
C ++ just gives you a richer set of ways to solve your programming problems, each of which has its pros and cons. There are many times when the best way is still the same as it would be in C. It would be vicious for a C ++ programmer to choose the worst way, simply because it was only possible in C ++. Nevertheless, such a choice exists on many levels, therefore, as a rule, they say that the member function is not [class-], which takes the const std::string& parameter, combining the call to the procedural function with the object-oriented data that was generated using template : everything works well together.
Tony delroy
source share