1

所以我收到这个错误

Error   1   error LNK2019: unresolved external symbol "public: enum LL_ERR __thiscall linkedList<int>::addData(int)" (?addData@?$linkedList@H@@QAE?AW4LL_ERR@@H@Z) referenced in function "public: enum S_ERROR __thiscall stack<int>::push(int const &)" (?push@?$stack@H@@QAE?AW4S_ERROR@@ABH@Z)  C:\Users\Spyder\Documents\Visual Studio 2010\Projects\stack_ll\stack_ll\stack__ll.obj   stack_ll

加上链接列表中我调用的每个函数的相同错误

我有 4 个文件。alinked_list.h、linked_list.cpp、stack_ll.h、stack_ll.cpp Linked_list.h 有类定义。linked_list.cpp 具有该类的所有功能。stack_ll.h 有另一个堆栈类,它使用链表存储所有内容。最后是 stack_ll.cpp,它具有堆栈加 main() 的功能。由于某种原因,链接器说没有定义链表类的任何功能。linked_list.cpp 包含在项目中。任何帮助将不胜感激。

4

1 回答 1

3

You haven't shown the code, but the problem is almost certainly that you've defined some class-template member functions in your .cpp file, rather than your .h file.

See the C++ FAQ: How can I avoid linker errors with my template classes?.

于 2012-01-22T22:25:32.437 回答