//Please consider the following
#include <iostream>
using namespace std;
typedef unsigned short USHORT;
enum ERR_CODE { SUCCESS, ERROR };
/* would ERR_CODE be kind of a type that tells the ERR_CODE Factor function the values that it can return? In turn telling the function that it can return the "type" of ERR_CODE which are either the value of SUCCESS which is zero or the value of ERROR which is one*/
ERR_CODE Factor(USHORT, USHORT&, USHORT&);
int main()
{
USHORT number, squared, cubed;
ERR_CODE result;
cout << "Enter a number (0 - 20): ";
cin >> number;
result = Factor(number, squared, cubed);
if (result == SUCCESS)
{
cout << "number: " << number << "\n";
cout << "square: " << squared << "\n";
cout << "cubed: " << cubed << "\n";
}
else
cout << "Error encountered!!\n";
int x; cin>>x;
return 0;
}
ERR_CODE Factor(USHORT n, USHORT &rSquared, USHORT &rCubed)
{
if (n > 20)
return ERROR; // simple error code
else
{
rSquared = n*n;
rCubed = n*n*n;
return SUCCESS;
}
}