error LNK2005该怎样解决呢?
RT错误列表
mention.obj : error LNK2005: "public: __thiscall mention::mention(void)" (??0mention@@QAE@XZ) already defined in ceshi.obj
mention.obj : error LNK2005: "public: virtual __thiscall mention::~mention(void)" (??1mention@@UAE@XZ) already defined in ceshi.obj
mention.obj : error LNK2005: "public: int __thiscall mention::Create(void)" (?Create@mention@@QAEHXZ) already defined in ceshi.obj
Debug/ceshi.exe : fatal error LNK1169: one or more multiply defined symbols found
执行 link.exe 时出错.
mention.obj : error LNK2005: "public: virtual __thiscall mention::~mention(void)" (??1mention@@UAE@XZ) already defined in ceshi.obj
mention.obj : error LNK2005: "public: int __thiscall mention::Create(void)" (?Create@mention@@QAEHXZ) already defined in ceshi.obj
Debug/ceshi.exe : fatal error LNK1169: one or more multiply defined symbols found
执行 link.exe 时出错.
代码:
ceshi.cpp
// ceshi.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "mention.cpp"
int main(int argc, char* argv[])
{
printf("Hello World!\n");
mention* men;
men=NULL;
men->Create();
return 0;
}
//
#include "stdafx.h"
#include "mention.cpp"
int main(int argc, char* argv[])
{
printf("Hello World!\n");
mention* men;
men=NULL;
men->Create();
return 0;
}
mention.cpp
// mention.cpp: implementation of the mention class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "mention.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
mention::mention()
{
}
mention::~mention()
{
}
mention::Create()
{
printf("123456");
}
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "mention.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
mention::mention()
{
}
mention::~mention()
{
}
mention::Create()
{
printf("123456");
}