再次请教关于error LNK2005的问题!急!
前几天这个帖子在论坛里发过了,但现在仍然没能解决,帖子很快就成下去了,因此决定重发一次,还往斑竹能够手下留情!编程时遇到一个关于error LNK2005的问题,不知道那位高手能帮我解决!不胜感激!
我定义了两个类,geo和coe。两个类的成员数据和成员函数的申明分别写在两个文件里,"geometrical.h","coeffcient.h"和"geometrical.cpp"和"coeffcient.cpp"。
同时,class coe: private geo
{
……………………
}
在每个".cpp"文件的开头都#include 对应的".h",如下所示(coe.cpp有所不同)
//geometrical.cpp
#include "geometrical.h"
………………
………………
//coeffcient.cpp
#include "geometrical.cpp"
#include "coeffcient.h"
………………
………………
最后在main()里:
#include "coefficient.cpp"
编译通过了,但在link时发生了如下的错误:
geometrical.obj : error LNK2005: "public: __thiscall geo::geo(double,double,double,int,int,int)" (??0geo@@QAE@NNNHHH@Z) already defined in coefficient.obj
geometrical.obj : error LNK2005: "protected: void __thiscall geo::fndimension(void)" (?fndimension@geo@@IAEXXZ) already defined in coefficient.obj
main.obj : error LNK2005: "public: __thiscall geo::geo(double,double,double,int,int,int)" (??0geo@@QAE@NNNHHH@Z) already defined in coefficient.obj
main.obj : error LNK2005: "protected: void __thiscall geo::fndimension(void)" (?fndimension@geo@@IAEXXZ) already defined in coefficient.obj
main.obj : error LNK2005: "public: __thiscall coe::coe(double,double,double,int,int,int)" (??0coe@@QAE@NNNHHH@Z) already defined in coefficient.obj
main.obj : error LNK2005: "public: void __thiscall coe::fncoedefine(void)" (?fncoedefine@coe@@QAEXXZ) already defined in coefficient.obj
main.obj : error LNK2005: "public: void __thiscall coe::fncoefficientF(double * * *,double * * *,double * * *,double,double)" (?fncoefficientF@coe@@QAEXPAPAPAN00NN@Z) already defined in coefficient.obj
main.obj : error LNK2005: "public: void __thiscall coe::fnDUVW(void)" (?fnDUVW@coe@@QAEXXZ) already defined in coefficient.obj
main.obj : error LNK2005: "public: void __thiscall coe::fncoefficientP(double)" (?fncoefficientP@coe@@QAEXN@Z) already defined in coefficient.obj
main.obj : error LNK2005: "public: void __thiscall coe::fnpseudoV(double * * *,double * * *)" (?fnpseudoV@coe@@QAEXPAPAPAN0@Z) already defined in coefficient.obj
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/test1.exe : fatal error LNK1120: 1 unresolved externals
每个头文件里都写了语句#pragma once,但仍然出现这种错误。
我又在每个头文件里写了
#ifndef ***.h
#define ***.h
………………
#endif
但还是不行。
小弟为VC++菜鸟,还往那位高手不惜赐教!万分感谢!