VC6.0程序运行报错error LNK2001,大神求解

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了VC6.0程序运行报错error LNK2001,大神求解相关的知识,希望对你有一定的参考价值。

/************************************************
邻接矩阵类MGraph的使用范例
*************************************************/
#include <iostream>
using namespace std;

const int MaxSize = 10; //图中最多顶点个数
int visited[MaxSize] = 0; //全局数组变量visited初始化
template <class DataType>
class MGraph

public:
MGraph(DataType a[ ], int n, int e); //构造函数,建立具有n个顶点e条边的图
~MGraph( ); //析构函数
void DFTraverse(int v); //深度优先遍历图
void BFTraverse(int v); //广度优先遍历图
private:
DataType vertex[MaxSize]; //存放图中顶点的数组
int edge[MaxSize][MaxSize]; //存放图中边的数组
int vertexNum, edgeNum; //图的顶点数和边数
;

template <class DataType>
MGraph<DataType> :: MGraph(DataType a[ ], int n, int e)

int i, j, k;
vertexNum = n; edgeNum = e;
for (i = 0; i < vertexNum; i++) //存储顶点
vertex[i] = a[i];
for (i = 0; i < vertexNum; i++) //初始化邻接矩阵
for (j = 0; j < vertexNum; j++)
edge[i][j] = 0;
for (k = 0; k < edgeNum; k++) //依次输入每一条边

cout << "请输入边依附的两个顶点的编号:";
cin >> i >> j; //输入边依附的两个顶点的编号
edge[i][j] = 1; edge[j][i] = 1; //置有边标志



template <class DataType>
void MGraph<DataType> :: DFTraverse(int v)

cout << vertex[v]; visited[v] = 1;
for (int j = 0; j < vertexNum; j++)
if (edge[v][j] == 1 && visited[j] == 0) DFTraverse( j );


template <class DataType>
void MGraph<DataType> :: BFTraverse(int v)

int w, j, Q[MaxSize]; //采用顺序队列
int front = -1, rear = -1; //初始化队列
cout << vertex[v]; visited[v] = 1; Q[++rear] = v; //被访问顶点入队
while (front != rear) //当队列非空时

w = Q[++front]; //将队头元素出队并送到v中
for (j = 0; j < vertexNum; j++)
if (edge[w][j] == 1 && visited[j] == 0 )

cout << vertex[j]; visited[j] = 1; Q[++rear] = j;




int main( )

int i;
char ch[ ]='A','B','C','D','E'; //测试数据六条边是:(0 1)(0 2)(0 3)(0 4)(1 2)(2 4) //
MGraph<char> MG(ch,5,6); //建立具有5个顶点6条边的无向图
for (i = 0; i < MaxSize; i++)
visited[i] = 0;
cout << "深度优先遍历序列是:" << endl;
MG.DFTraverse(0); //从顶点0出发进行深度优先遍历
for (i = 0; i < MaxSize; i++)
visited[i] = 0;
cout << "广度优先遍历序列是:" << endl;
MG.BFTraverse(0); //从顶点0出发进行广度优先遍历
return 0;

参考技术A 你要给出具体错误信息,LNK2001的错误也又细节的 参考技术B

    CClientDlg 类的头文件没有包含 外部函数或者外部变量没有引用

参考技术C CClientDlg 类的头文件没有包含 外部函数或者外部变量没有引用追问

可否细说一下如何修改?

以上是关于VC6.0程序运行报错error LNK2001,大神求解的主要内容,如果未能解决你的问题,请参考以下文章

error LNK2001: unresolved external symbol __imp__WSAStartup@8 SOCKET(转)

VC6 LINK : fatal error LNK1168: cannot open Debug/Test.exe for writing

error LNK2001: 无法解析的外部符号

error LNK2001: 无法解析的外部符号

error LNK2001: 无法解析的外部符号

C++ error LNK2001: 无法解析的外部符号