Function question

I have a function that must be used by a set of classes; these classes are not related by inheritance. What would be the best way to make this function accessible to all my classes?

Put the function prototype in a header file and #include that header file in the class definition files.
Last edited on
Thank you Moschops. What about the function body? separate .cpp file?
Yes. Function definition in a single cpp file, a header file containing the prototype. Every file that uses the function has the header included at the top, and the cpp file is compiled and linked as normal, like all the other cpp files.
Got it, thanks!
Topic archived. No new replies allowed.