注册 登录
编程论坛 C++教室

出现编译错误请求帮忙解决

hsnr 发布于 2010-04-04 18:04, 358 次点击
我用C++语言编写了如下程序,编译中出现错误信息:
try error LNK2019: 无法解析的外部符号 "public: __thiscall ChebyshevPolynomial::~ChebyshevPolynomial(void)" (??1ChebyshevPolynomial@@QAE@XZ) ,该符号在函数 "public: double __thiscall ChebyshevPolynomial::ChebyshevOneDifferential(void)" (?ChebyshevOneDifferential@ChebyshevPolynomial@@QAENXZ) 中被引用
怎么解决?请高手帮忙了。
源程序为:
#include "stdafx.h"
#include<cmath>
using namespace std;

class ChebyshevPolynomial
{
private:
    int iDegree;
    int nOrder;
    double dxVariable;
public:
    ChebyshevPolynomial(int iLocal,int nLocal,double xLocal);
    double ChebyshevFunction( );
    double ChebyshevLimitedPoint( );
    double ChebyshevOneDifferential( );  
    ~ChebyshevPolynomial( );
};

ChebyshevPolynomial::ChebyshevPolynomial(int iLocal,int nLocal,double xLocal)
{
iDegree=iLocal;
nOrder=nLocal;
dxVariable=xLocal;
}

double ChebyshevPolynomial::ChebyshevFunction( )
{
    return(cos(iDegree*acos(dxVariable)));
}


double ChebyshevPolynomial::ChebyshevLimitedPoint( )
{
    double pi=3.1415926;
    return(-cos(iDegree*pi/nOrder));
}

double ChebyshevPolynomial::ChebyshevOneDifferential( )
{
    double ci,cj,xVariable,TjXi,TjX,hk_x(0);
    int j;

    if(iDegree==0||iDegree==nOrder)
        ci=2;
    else
        ci=1;

    xVariable=ChebyshevLimitedPoint( );

    for(j=0;j<=nOrder;j++)
    {
        if(j==0||j==nOrder)
            cj=2;
        else
            cj=1;


        ChebyshevPolynomial(j,nOrder,xVariable);
        TjXi=ChebyshevFunction( );

        ChebyshevPolynomial(j,nOrder,dxVariable);
        TjX=ChebyshevFunction( );

        hk_x+=TjXi*TjX/cj;
    }
    return(2*hk_x/nOrder/ci);
}


int _tmain(int argc, _TCHAR* argv[])
{
    ChebyshevPolynomial Chebyshev(1,4,0.5);

    cout<<"Chebyshev.ChebyshevFunction( )"<<Chebyshev.ChebyshevFunction( )<<endl;
    cout<<"Chebyshev.ChebyshevLimitedPoint( )"<<Chebyshev.ChebyshevLimitedPoint( )<<endl;
    cout<<"Chebyshev.ChebyshevOneDifferential( )"<<Chebyshev.ChebyshevOneDifferential( )<<endl;

    return 0;
}


3 回复
#2
cnfarer2010-04-04 18:24
public:
    ChebyshevPolynomial(int iLocal,int nLocal,double xLocal);
    double ChebyshevFunction( );
    double ChebyshevLimitedPoint( );
    double ChebyshevOneDifferential( );
    ~ChebyshevPolynomial( ){};  //加上就行了!
#3
hsnr2010-04-04 18:55
太谢谢!是我疏忽。
#4
hsnr2010-04-04 20:48
回复 3楼 hsnr
接上面的问题(同一个程序)。不过现在是运行上的问题,再请高手指点。在以下语句中
 ChebyshevPolynomial(j,nOrder,xVariable);
 TjXi=ChebyshevFunction( );

 ChebyshevPolynomial(j,nOrder,dxVariable);
 TjX=ChebyshevFunction( );
我本意是想通过构造函数ChebyshevPolynomial改变成员变量的值,然后计算出相应的函数值,可是我发现这样无法改变变量的值。怎么回事?要想做到这点,该如何做?谢谢了!
1