0

Can please define headers

10th Jul 2017, 3:44 PM
Krlldread Force
3 Antworten
0
files which have includes, functions, classes, global variables and macros and you can include in more than one source file
10th Jul 2017, 3:51 PM
Andrés04_ve
Andrés04_ve - avatar
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); }
10th Jul 2017, 3:58 PM
Andrés04_ve
Andrés04_ve - avatar
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; }
10th Jul 2017, 7:34 PM
Ali Rashidi
Ali Rashidi - avatar