I have program.cpp which contains main function. There is a class Tracker which is used in the main function. program.cpp also contains a bunch of utility functions (a function to check if the file passed as an argument to the program exists for example). I want to move these utility functions out of program.cpp. How should I do this:
- make
utils.cppcontaining the functions as they are, put the prototypes intoutils.h, includeutils.hinsideprogram.cppand compile asg++ ... program.cpp utils.cpp - or, make
utils.ha class with no private members, just have all the functions as public, implement them inutils.cppand then use them inprogram.cppasUtils utils; utils.stuff(...);
There is no reason to create a class if you don’t need one (especially not just a class for a few unrelated functions). I would choose your first option, and declare the function prototypes as they are in
util.h.