I'm a little confused about the use of header-only files in cpp . From my understanding, I need to declare all functions and variables with "inline". For classes/structs, I don't need to apply inline because it's already declared implicit.
Example: In app.hpp file
namespace app{
inline void func1(){#do sth};
inline int num;
class application{
void func2();//this should be fine;
void int num2;
}
}
Why it's necessary to declare all variables and functions with inline? It works properly if I declare function in .hpp and define functions in .cpp files without inline, but I have to do header-only.If not using inline, it will shows multiple-definition error.(If I declare with static instead of inline, it shows not error at compile time but shows wrong outputs when I run it) Thanks for anybody's help!