How can I create bunch of methods that doesn’t depend on any object ( in my file there is no classes , no objects , no main , nothing but the methods) all in one cpp/hpp file and how to declare them ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want them to be public, i.e. available in multiple translation units, the best way is to include them in a
namespace, declare them in the header and implement them in a single implementation file:IMPORTANT
If you provide the definition in the header, you should mark them
inline, otherwise including that header in multiple translation units might result in a linker error:If you only want them available in a translation unit, define them in that implementation file in an anonymous namespace (or declare them
static):