struct中未解析的外部符号lnk2001

时间:2014-06-06 23:50:41

标签: c++ struct compiler-errors

我试图将黄金比例和pi计算器转换为此程序,并涉及制作数字结构。

#include iostream
#include fstream
#include iomanip

using namespace std;

// global variable
struct Number
{
    int value;
    double FibCalc( int value );
};

Number n;
int prec;

int main()
{
    ofstream outFile;      // file containing output
    outFile.open("output.txt");

    cout << endl << "Input Fibonnaci Base : ";
    cin >> n.value;
    cout << endl << "Enter Precision : ";
    cin >> prec;
    cout << "Fibonnaci " << n.value << " = " << setprecision( prec ) << n.FibCalc( n.value) << endl;
    outFile << "Fibonnaci " << n.value << " = " << setprecision( prec ) << n.FibCalc( n.value) << endl;
}

int FibCalc( /* in */ int value )
// Pre:  n is has been inputed
// Post: function value is nFib
// Note: large exponents may result in integer overflow
{
    //cout << "Calling " << n << endl;
    if ( value==0 || value==1 )                             // base case
        return value;
    else if ( value > 1 )   
        return  FibCalc( value-2 ) + FibCalc( value-1 ) ;    // recursive call
}

但是当我尝试运行n.FibCalc( n.value)命令时,我收到以下错误消息:

  

LNK2001: unresolved external symbol "public: double_thiscall Number::FibCalc(int)" (?FibCalc@Number@@QAENH@Z)

  • 如何解决此错误?

0 个答案:

没有答案