Creating the custom made C/C++ header file in C++ programming which is reusable

 

Compiler: Visual C++ Express Edition 2005

Compiled on Platform: Windows XP Pro SP2

Header file: Standard

Additional project setting: Set project to be compiled as C++

Project -> your_project_name Properties -> Configuration Properties -> C/C++ -> Advanced -> Compiled As: Compiled as C++ Code (/TP)

Other info: none

To do: Creating the custom made C/C++ header file in C++ programming

To show: How to create our own header file, arithmet.h in C++ programming

 

// arithmet.h header file, no need to compile or run.

// A user defined function and header file, a simple arithmetic functions. The variable also has been change to x and y respectively.

// The important one are parameter type, number and return types must match

#include <iostream>

using namespace std;

 

// global variables

float x, y;

 

// function prototypes

float AddNum(float, float);

float SubtractNum(float, float);

float DivideNum(float, float);

float MultiplyNum(float, float);

 

float AddNum(float x, float y)

{

return (x + y);

}

 

float SubtractNum(float x, float y)

{

return (x - y);

}

 

float DivideNum(float x, float y)

{

// divide by 0 check

if(y==0)

return 0;

else

return (x / y);

}

 

float MultiplyNum(float x, float y)

{

return (x * y);

}

// no output

 

 

C and C++ Programming Resources | C & C++ Code Example Index