I am trying to call a function from an external file to a source file. However, when I do so I'm getting the following error:
Why am I getting the following errors? I've been trying to get my head around it all day, but it has all been in vain. P.S I'm am very new to the language and programming in general. Past experience: Python
source.cpp
#include <iostream>
#include <string>
#include "func.cpp"
using namespace std;
double pow(double x, int y);
int main()
{
double x;
int y;
double answer;
cout << "Choose a number: " << endl;
cin >> x;
cout << "Raised to the power: " << endl;
cin >> y;
answer = pow(x, y);
cout << "Answer: " << answer << endl;
return answer;
}
func.cpp
double pow(double x, int y)
{
double result = 1;
if (x == 0 && y == 0)
{
result = -1;
}
else
{
if (y == 0)
{
result = 1;
}
else if (y < 0)
{
x = 1.0 / x;
y *= -1;
}
for (int i = 0; i < y; i++)
{
result *= x;
}
}
return result;
}