新年散分!!!!学习
在".h"文件中定义了初始化的全局变量:
int a[100]; // 用来存放编码的数组
int maxsize(0); // 用来记录编码的长度
static int count; // 用来记录字符的长度
int number(0); //存放字符串的长度
这些均只在".cpp"文件中用到:
可编译时出现如下的:
huffman.obj : error LNK2005: "int __cdecl len(char * const)" (?len@@YAHQAD@Z) already defined in huffmanmain.obj
huffman.obj : error LNK2005: "public: __thiscall hufftree::hufftree(void)" (??0hufftree@@QAE@XZ) already defined in huffmanmain.obj
huffman.obj : error LNK2005: "public: void __thiscall hufftree::Insert(int,char)" (?Insert@hufftree@@QAEXHD@Z) already defined in huffmanmain.obj
huffman.obj : error LNK2005: "public: void __thiscall hufftree::connect(class huffnode *)" (?connect@hufftree@@QAEXPAVhuffnode@@@Z) already defined in huffmanmain.obj
huffman.obj : error LNK2005: "public: class huffnode * __thiscall hufftree::Min(void)" (?Min@hufftree@@QAEPAVhuffnode@@XZ) already defined in huffmanmain.obj
huffman.obj : error LNK2005: "public: void __thiscall hufftree::Frequence(char * const)" (?Frequence@hufftree@@QAEXQAD@Z) already defined in huffmanmain.obj
huffman.obj : error LNK2005: "public: void __thiscall hufftree::Sethufftree(void)" (?Sethufftree@hufftree@@QAEXXZ) already defined in huffmanmain.obj
huffman.obj : error LNK2005: "public: void __thiscall hufftree::Inorder(class huffnode *)" (?Inorder@hufftree@@QAEXPAVhuffnode@@@Z) already defined in huffmanmain.obj
huffman.obj : error LNK2005: "public: void __thiscall hufftree::output(void)" (?output@hufftree@@QAEXXZ) already defined in huffmanmain.obj
huffman.obj : error LNK2005: "public: void __thiscall hufftree::delet(class huffnode *)" (?delet@hufftree@@QAEXPAVhuffnode@@@Z) already defined in huffmanmain.obj
huffman.obj : error LNK2005: "public: void __thiscall hufftree::huffcode(void)" (?huffcode@hufftree@@QAEXXZ) already defined in huffmanmain.obj
huffman.obj : error LNK2005: "public: void __thiscall hufftree::outputcode(void)" (?outputcode@hufftree@@QAEXXZ) already defined in huffmanmain.obj
huffman.obj : error LNK2005: "public: void __thiscall hufftree::sortcode(void)" (?sortcode@hufftree@@QAEXXZ) already defined in huffmanmain.obj
huffman.obj : error LNK2005: "public: void __thiscall hufftree::Incode(char * const)" (?Incode@hufftree@@QAEXQAD@Z) already defined in huffmanmain.obj
huffman.obj : error LNK2005: "public: void __thiscall hufftree::transcode(void)" (?transcode@hufftree@@QAEXXZ) already defined in huffmanmain.obj
huffman.obj : error LNK2005: "int number" (?number@@3HA) already defined in huffmanmain.obj
huffman.obj : error LNK2005: "int maxsize" (?maxsize@@3HA) already defined in huffmanmain.obj
huffman.obj : error LNK2005: "int * a" (?a@@3PAHA) already defined in huffmanmain.obj
Debug/huffman.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
上面显示的是:我”。cpp“文件中的成员函数与这些全局变量均被在主函数中被重复定义,可我没有呀
在".h"文件中用了”#pragma once“也不行,请高手帮忙!!!