Should functions not be in Header (.h) files?

Is it standard for functions only to be in .cpp files while in .h files just declare the functions but dont write the logic? Is there anything wrong with functions in .h files or is it purely opinion

Most of the time it is preferred to have the functions entirely in C++ files, because if you need to change the logic it means you don't also need to recompile every file that depends on the header file. However, some functions (mostly one-liner set/get or similar functions) are fine to put in header files, and can give a small boost in efficiency if you do so, because the compiler can inline the function into anything that calls them. Some other functions MUST be declared in header files, too, like template functions.
Topic archived. No new replies allowed.