链接错误lnk2019

发布于 2024-12-28 17:51:14 字数 723 浏览 4 评论 0原文

所以我得到这个错误

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个文件。一个linked_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 包含在项目中。任何帮助将不胜感激。

so im getting this error

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

plus the same errors for each function I call that is in the linked list

I have 4 files. a linked_list.h, linked_list.cpp, stack_ll.h, stack_ll.cpp
Linked_list.h has the class definition. linked_list.cpp has all the functions of said class. stack_ll.h has another class for a stack that stores everything using the linked list. and finally stack_ll.cpp that has the functions for the stack plus main(). For some reason the linker is saying that none of the functions of the linked list class have been defined. linked_list.cpp is included in the project. Any help would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦里南柯 2025-01-04 17:51:14

您尚未显示代码,但问题几乎可以肯定是您在 .cpp 文件而不是 .h 文件中定义了一些类模板成员函数。

请参阅 C++ 常见问题解答:如何避免链接器错误我的模板类?

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?.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文