Is it needed to put function declarations in header files and their definitions in a source files? Is there any performance gain, or possibly any advantage to doing this instead of putting the declarations and definitions in the same file? Example:
In Person.h
class Person() {
public:
void sayHi();
}
and in Person.cpp
#include "Person.h"
#include <cstdio>
void Person::sayHi() {
printf("Hello, world!\n");
}
versus just having it in one file:
#include <cstdio>
class Person {
void sayHi() {
printf("Hello, world!\n");
}
}