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里都有定义,当然重定义了