0
Can please define headers
3 Antworten
0
files which have includes, functions, classes, global variables and macros and you can include in more than one source file
0
for example:
header:
#include <stdio.h>
#define PI 3.14159
double area(double r){
return 2*PI*r;
}
source:
#include "header.h";
int main(){
float r;
scanf("%f",&r);
printf("Area = 2 * %f * %f = %f", PI, r, area(r)),
return 0;
}
another source:
#include "header.h"
int main(){
printf("The value of pi is %f",PI);
}
0
headers store the definitions of classes, variables, etc. While source files keep the code. Example:
sum.h (header):
class Sum{
public:
Sum (int a, int b);
int getResult ();
private:
int result;
};
--------
sum.cpp (source)
#include "sum.h"
Sum::Sum (int a, int b){
result = a + b;
}
int Sum::getResult (){
return result;
}