Kobe___Bryant 2016-05-16 12:45 采纳率: 0%
浏览 6123

关于c++ error LNK2019: unresolved external symbol 问题

我运行了一个程序,报出如下错:
Error 1 error LNK2019: unresolved external symbol "public: __thiscall CircList::CircList(int)" (??0?$CircList@N@@QAE@H@Z) referenced in function _wmain
Error 2 error LNK2019: unresolved external symbol "public: __thiscall CircList::~CircList(void)" (??1?$CircList@N@@QAE@XZ) referenced in function _wmain
Error 3 error LNK2019: unresolved external symbol "public: struct CircListNode * __thiscall CircList::Locate(int)" (?Locate@?$CircList@N@@QAEPAU?$CircListNode@N@@H@Z) referenced in function "void __cdecl Josephus(class CircList &,int,int,int)" (??$Josephus@N@@YAXAAV?$CircList@N@@HHH@Z)

Error 4 error LNK1120: 3 unresolved externals
程序代码如下:

 #ifndef CIRCLIST_H_
#define CIRCLIST_H_

template <class T>
struct CircListNode{
    T data;
    CircListNode<T> * link;
};

template <class T>
class CircList{
private:
    CircListNode<T> * first;
public:
    CircList(){}
    CircList(int i);
    ~CircList();
    CircListNode<T> * Locate(int i);
};
#endif
 #include "stdafx.h"
#include "circList.h"
#include <iostream>

using namespace std;

template<class T>
CircList<T>::CircList(int i)
{
    T value;
    first = new CircListNode < T > ;
    for (int j = 0; j < i; j++)
    {
        CircListNode<T> * newNode = new CircListNode < T > ;
        cout << "请输入第" << j + 1 << "个节点的值:";
        getline(cin, value);
        newNode->data = valude;
        newNode->link = first->link;
        first->link = newNode;
    }
    cout << "一个包含" << i << "个节点的循环表建立成功!" << endl;
}

template<class T>
CircList<T>::~CircList()
{
    CircListNode<T> * q;
    while (first->link != NULL)
    {
        q = first->link;
        first->link = q->link;
        delete q;
    }
    delete first;
}

template<class T>
CircListNode<T> * CircList<T>::Locate(int i)
{
    CircListNode<T> * current = new CircListNode < T > ;
    if (current == NULL)
    {
        cout << "内存分配错误!" << endl;
        return NULL;
    }
    else
    {
        current = first->link;
        for (int j = 1; j < i - 1; j++)
            current = current->link;
        return current;
    }
}
 // ex2-5.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include "circList.h"

using namespace std;

template<class T>
void Josephus(CircList<T> & js, int n, int s, int m);

int _tmain(int argc, _TCHAR* argv[])
{
    int n, s, m;
    cout << "请输入游戏人数、开始位置和报数间隔: ";
    cin >> n >> s >> m;
    CircList<double> clist(n);
    Josephus(clist, n, s, m);
    return 0;
}

template<class T>
void Josephus(CircList<T> & js, int n, int s, int m)
{
    CircListNode<T> * p = js.Locate(s), *pre = NULL;
    for (int i = 0; i < n - 1; i++)
    {
        for (int j = 1; j < m; j++)
        {
            pre = p;
            p = p->link;
        }
        cout << "出列的人是" << p->data << endl;
        pre->link = p->link;
        p = pre->link;
    }
}

求大神解释一下,谢谢了

  • 写回答

4条回答 默认 最新

  • Robot-S 2016-05-16 12:52
    关注

    main.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall CvSVM::~CvSVM(void)" (??1CvSVM@@UAE@XZ) referenced in function _main
    1>main.obj : error LNK2019: unresol......
    答案就在这里:error LNK2019: unresolved external symbol 问题
    ----------------------Hi,地球人,我是问答机器人小S,上面的内容就是我狂拽酷炫叼炸天的答案,除了赞同,你还有别的选择吗?

    评论

报告相同问题?

悬赏问题

  • ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
  • ¥30 STM32 INMP441无法读取数据
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥500 把面具戴到人脸上,请大家贡献智慧,别用大模型回答,大模型的答案没啥用
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。
  • ¥15 各位 帮我看看如何写代码,打出来的图形要和如下图呈现的一样,急
  • ¥30 c#打开word开启修订并实时显示批注
  • ¥15 如何解决ldsc的这条报错/index error