Hi all,
if i have the following
a header file called "temp.h" :
Code:
#ifndef TEMP_H
#define TEMP_H
double to_celsius(double fahrenheit);
#endif
the temp.cpp file :
Code:
#include "temp.h"
double to_celsius(double fahrenheit){
double celcius = (fahrenheit - 32) * 5.0 / 9.0;
return celcius;
}
the main.cpp:
Code:
#include "temp.h"
int main() {
cout << to_celsius(32) << endl;
return 0;
}
My question, is it necessary to include the header in "temp.cpp" and "main.cpp" ? or is it enough only "main.cpp" (because it works for me when i include it only in main.cpp).
are there different cases? or is there some best practice?
any hints or links to read more about it is appreciated