关于在MFC中添加头文件

来源:百度知道 编辑:UC知道 时间:2024/05/27 04:02:18
用的VC6.0,在MFC中添加了头文件“BST.h”,(工程名字是“本地爬虫”)在“本地爬虫.h”里面#include "BST.h",并且extern BSGraph graph;以建立全局变量,但是,一编译,出现了无数错误:

Linking...
MainFrm.obj : error LNK2005: "public: int __thiscall GraphNode::cmp(class GraphNode)" (?cmp@GraphNode@@QAEHV1@@Z) already defined in GrabDialog.obj
MainFrm.obj : error LNK2005: "private: class BinaryTreeNode * __thiscall BSGraph::Search(class BinaryTreeNode *,class BinaryTreeNode *)" (?Search@BSGraph@@AAEPAVBinaryTreeNode@@PAV2@0@Z) already defined in GrabDialog.obj
MainFrm.obj : error LNK2005: "public: bool __thiscall BSGraph::PushLink(class GraphNode)" (?PushLink@BSGraph@@QAE_NVGraphNode@@@Z) already defined in GrabDialog.obj
MainFrm.obj : error LNK2005: "public: void __thiscall BSGraph::DeleteBinaryTree(class BinaryTreeNode *)" (?DeleteBinaryTree@BSGraph@@QAEXPAVBinaryTreeNode@@@Z) already defined in GrabDialog.obj
MainFrm.obj : error LNK2005: "private: int __thiscall B

都是头文件重复编译的问题
使用
#ifndef XXXXXXXXXXXX_H
#define XXXXXXXXXXXX_H
代码
#endif

你先用
#ifdef BAT_H_H
#define BAT_H_H
...
...
...
#endif 语句试试

还有可能是不有依赖的lib

去属性页看看 什么情况