1.为ä»ä¹ifåå #
为ä»ä¹ifåå #
è¿æ¯ä¸ºäºé²æ¢å¤´æ件被éå¤å å«ãéå¤å å«å¯ä»¥ç¨ä¸é¢çä¾åæ¥è¯´æï¼æ¯å¦
æ个头æ件
a.h
ï¼éé¢æ个å½æ°
Fa
ï¼å¦ä¸ä¸ªå¤´æ件
b.h
ï¼éé¢æå½æ°
Fb,源码uplink源码
Fb
çå®
ç°éè¦ç¨å°
Fa
ï¼å
b.h
ä¸éè¦å å«
a.h
ï¼æ个
cpp
æ件ä¸çå½æ°éè¦ç¨å°
Fa
å
Fb
ï¼åéè¦å å«
a.h
å
b.h
ï¼æ¤æ¶
a.h
å°±åçäºéå¤å å«ãç¼è¯ç¨åºï¼åºç°å¦ä¸é
误ï¼
error C: function 'bool __cdecl Fa()' already has a body
解å³åæ³æ¯å¨
a.h
çä¸å å ¥ï¼
#ifndef A
#define A
åæ¥ç代ç
#endif
示ä¾æºä»£ç æ¸ åå¦ä¸ï¼
// a.h
#ifndef A
#define A
bool AorB(bool a)
{
return a;
}
#endif
// b.h
#include "a.h"
bool CorD(bool a)
{
return AorB(a);
}
// a.cpp
#include "a.h"
#include "b.h"
int main()
{
bool a = 0;
bool b = AorB(a);
bool c = CorD(b);
getchar();
return 0;
}
2024-12-22 10:43
2024-12-22 09:45
2024-12-22 09:18
2024-12-22 09:15
2024-12-22 08:48
2024-12-22 08:39