我在一个sdi程序中加入了一个类
,      没有使用其它lib class CPoint2D;class CPoint2D
{
public:
    CPoint2D():x(0),y(0)
    {
    }
CPoint2D(double x, double y):x(x), y(y)
{
}
CPoint2D operator+( const CVector2D &v );
friend CPoint2D operator+( const CPoint2D &p1, const CPoint2D &p2 );
CVector2D operator-( const CPoint2D &v );
friend CPoint2D operator/( const CPoint2D &p, double scale );
double x;
double y;
};编译后出现如下 link error
DemoFaceChangedView.obj : error LNK2001: unresolved external symbol "class CPoint2D  __cdecl operator+(class CPoint2D const &,class CPoint2D const &)" (??H@YA?AVCPoint2D@@ABV0@0@Z)DemoFaceChangedView.obj : error LNK2001: unresolved external symbol "class CPoint2D  __cdecl operator/(class CPoint2D const &,double)" (??K@YA?AVCPoint2D@@ABV0@N@Z)
请问如何解决?谢谢

解决方案 »

  1.   

    把你lib放进Project->Settings->Link->>(Edit  框)Object/Library Modules(如Vfw32.lib )
    就可以
      

  2.   

    不是啊,老兄,我没有用到其他的lib啊,就是加入了CPoint2D 这个类啊
      

  3.   

    LNK2001可能是找不到类型(CPoint2D)的实现,也可能是找到了多个,而无法确定。在头文件中包含了:
    #ifndef __CPOTNT2D_H__
    #define __CPOINT2D_H__
    //类声明
    //...
    #endif
      

  4.   

    这个错误是说没有找到+ / 运算符的实现函数。
    原因就是:
    1。你没有实现它;
    2。虽然实现了,但你没有把它加入工程,以让编译器找到(例如CPP文件里)或者连接器找到(LIB或OBJ里)。