I am having some problems with an error I do not understand it looks to me the exact same as in the book. Here is the code and the given error.
Code:
Code:
#include <iostream>
using namespace std;
enum ERR_CODE {SUCCESS, ERROR};
ERR_CODE Factor(int, int&, int&); // Function prototype
int main()
{
int number, squared, cubed;
ERR_CODE result;
cout << "Enter a number (0-20): " ;
cin >> number;
result = Factor(number, squared, cubed);
if(result == SUCCESS)
{
cout << "Nunber:\t\t" << number << endl;
cout << "Squared:\t\t" << squared << endl;
cout << "Cubed:\t\t" << cubed << endl;
}
else
{
cout << "Error encountered!!" << endl;
}
return 0;
}
ERR_CODE Factor(int n, int rSquared, int rCubed)
{
if (n > 20)
{
return ERROR; // Simple error code
}
else
{
rSquared = n*n;
rCubed = n*n*n;
return SUCCESS;
}
}
Error:
Line:15 Undefined reference to 'Factor(int, int&, int&)'