Understand that the header/implementation/driver distinction is really of importance for larger programs. Headers and implementation are generally seperated for compiling efficiency.
You appear to be confused on terms. Here is a very bare-bones 3-file program which converts between temperature formats.
This is the header file.
Code:
// Header files should only contain function prototypes.
float farenheit_to_celcius (float celcius);
This is the implementation file.
Code:
#include "f2c.hpp"
// The implementation file contains the functions which are prototyped in the header.
// Convert from farenheit temperature to Celcius.
float farenheit_to_celcius (float farenheit) {
return (farenheit - 32) * 5.0 / 9.0;
}
This is the driver.
Code:
#include <iostream>
#include "f2c.hpp"
// The driver function is the one that actually -uses- the functions prototyped in the header.
int main (void) {
float celcius;
float farenheit;
std::cin >> farenheit;
celcius = farenheit_to_celcius (farenheit);
std::cout << celcius;
return 0;
}
Note that we have two .cpp files which rely on each other. We have to compile them together, using this command (assuming you are using linux)
Code:
$ g++ main.cpp f2c.cpp