I have two files and I would like to call addition function from functions.cpp in main.cpp. But I get error:
In function `int main()':
error: `addition' has both `extern' and initializer
error: initializer expression list treated as compound expression
warning: left-hand operand of comma has no effect
error: `addition' cannot be used as a function|
||=== Build finished: 3 errors, 1 warnings ===|
Here are files
main.cpp
#include <iostream>
using namespace std;
int main()
{
int summation;
int a, b;
cout <<"Please Enter the two digits to add"<<endl;
cin>>a>>b;
//add external f(x) from function.cpp
extern int addition(a, b);
summation = addition(a, b);
cout<<"The sum is "<<summation;
return 0;
}
functions.cpp
int addition(int a, int b)
{
int sum;
sum = a+b;
return(sum);
}