Hello, im having trouble using a function from another file in a project,
this is a example from my book:
Calling a function with only a prototype:
Code:
#include <iostream>
using namespace std;
void BigDog(int KibblesCount);
int main()
{
BigDog(3);
return 0;
}
Using a function from a seperate file:
Code:
#include <iostream>
using namespace std;
void BigDog(int KibblesCount)
{
cout << "I'm a lucky dog" << endl;
cout << "I have " << KibblesCount << " pieces of food" << endl;
}
i know how this example works but, i tried making my own:
I make a prototype and made the function:
Code:
#include <iostream>
using namespace std;
int Sum(int x,int y);
int main(){
cout << "Type 2 numbers" << endl;
cout << Sum(30,20) << endl;
}
int Sum(int x,int y){
int result;
result = x + y;
return result;
}
Here i tried making the file where i was going to use the Sum(int x,int y) function:
Code:
#include <iostream>
using namespace std;
int Sum(int x,int y)
{
cout << "The number is " << Sum(x,y) << endl;
}
but i dont know how to program this file so it'll be able to use the Sum function.
Any help?