15.obj : error LNK2005: "public: __thiscall Item_base::Item_base(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,double)" (??0Item_base@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@s
td@@N@Z) already defined in Base_item.obj15.obj : error LNK2005: "public: virtual double __thiscall Item_base::TotalPrice(unsigned int)const " (?TotalPrice@Item_base@@UBENI@Z) already defined in Base_item.obj15.obj : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall Item_base::Get_isbn(void)const " (?Get_isbn@Item_base@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@
std@@XZ) already defined in Base_item.objBase_item.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall Item_base::~Item_base(void)" (??1Item_base@@UAE@XZ)15.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall Item_base::~Item_base(void)" (??1Item_base@@UAE@XZ)
Debug/15.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.请问这是什么问题? 好像常发生,特别是有多个文件时

解决方案 »

  1.   

    5.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall Item_base::~Item_base(void)" (??1Item_base@@UAE@XZ)15.obj : error LNK2001: unresolved external symbol "public: __thiscall Item_base::Item_base(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,double)" (??0Item_base@@QAE@ABV?$basic_string@DU?$char_traits
    @D@std@@V?$allocator@D@2@@std@@N@Z)Debug/15.exe : fatal error LNK1120: 2 unresolved externals
    现在成这样了!
      

  2.   

    再把 构造函数 和 析构函数的定义从 .cpp 移到 .h
    怎么就可以了呢?
    谁能告诉我?  请帮帮忙! 谢谢!
      

  3.   

    上面的提示说是找不到函数的实现体.
    .h 即头文件一般是用来被别的 .c/.cpp 文件包含, 编译器可通过它找到在其中声名的函数的实现体.
      

  4.   

    原来是我在主cpp里引用了实现类的cpp文件
    为什么 我只要引用定义类的.h文件就可以了呢?
    那编译器是怎么找到类的定义的?
    求教!