首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

error LNK2005 已定義於.解决思路

2012-01-23 
error LNK2005 已定義於..??general.h的內容#includestdafx.h #ifndefGENERAL_H#defineGENERAL_HboolIsF

error LNK2005 已定義於..??
general.h的內容

#include   "stdafx.h "
#ifndef   GENERAL_H
#define   GENERAL_H
bool   IsFileExist   (CString   strFileName)
{
CFile   fle;
if   (fle.Open   (strFileName,   CFile::modeRead)   )
{
fle.Close();
return   true;
}
return   false;
}
#endif

在B.cpp
#include   "A.h "
#include   "general.h "

在A.cpp
#include   "general. "

error   LNK2005:   "bool   __cdecl   IsFileExist(class   ATL::CStringT <char,class   StrTraitMFC_DLL <char,class   ATL::ChTraitsCRT <char>   >   > ) "   (?IsFileExist@@YA_NV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@@Z)   已經定義於   A.obj

[解决办法]
头文件只声明函数,把实现放到cpp文件里。
[解决办法]
在A和B的cpp文件里都包含了general.h,则IsFileExist函数在A和B里都有定义,当然重定义了

热点排行