I have a program to find the reciprocal of a number but the main program is written in C and the reciprocal
function is written in c++.Next I have a header file reciprocal.hpp
that has some of the conditional compilation code that makes the reciprocal
function an extern function.Can someone please explain me what is there in the reciprocal.hpp
program.
main.c
#include<stdio.h>
#include<stdlib.h>
int main(int argc,char **argv)
{
int i;
i = atoi(argv[1]);
printf("\nThe reciprocal of %d is %f\n",i,reciprocal(i));
return 0;
}
reciprocal.cpp
#include<cassert>
#include "reciprocal.hpp"
double reciprocal(int i)
{
assert( i != 0);
return 1.0/i;
}
reciprocal.hpp
#ifdef __cplusplus
extern "C"
{
#endif
extern double reciprocal(int i);
#ifdef __cplusplus
}
#endif
I don't understand what is happening in reciprocal.hpp
.Please help!!