编译问题,答对一定给分,从来都是说话算数!请高手帮助
我用VC++ 6.0写程序时,如果将几个函数分成几个文件,如这样:
假设有:void Draw(..) , BOOL Judge(..) , int WINAPI WinMain(..),BOOL InitWindow(...),
HRESULT CALLBACK WinProc(...), BOOL InitDDraw();
将int WINAPI WinMain(..),BOOL InitWindow(...),
HRESULT CALLBACK WinProc(...), BOOL InitDDraw();
放在一个ex.cpp的主文件中
void Draw(..) , BOOL Judge(..)
放在一个dd.cpp的文件中
并且在dd.cpp中#include "dd.h"文件进行函数声明。
再在主文件ex.cpp中#include "dd.cpp"
结果,出现如下的编译错误:
ex06.cpp
DDsur.cpp
G:\VCout\ex06\ddsur.h(5) : error C2146: syntax error : missing ';' before identifier 'InitDDraw'
G:\VCout\ex06\ddsur.h(5) : error C2501: 'BOOL' : missing storage-class or type specifiers
G:\VCout\ex06\ddsur.h(5) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
ex06.exe - 3 error(s), 0 warning(s)
这是为什么?就算我在dd.h文件前后使用#ifndef #define .... #endif的方法也没有用!
另外,我把DDutil.cpp和DDutil.h文件这样调入主文件ex.cpp中:
#include "ddutil.cpp"
就会出现错误警告!警告的大概内容是DDutil.cpp中的“函数已经定义”。为什么?
还有这个VC++中,工作区里的文件,我不把它加入到工作区里来,也一样可以#include "...",那把程序加
到工作区里来又有什么意义。
以上几个问题,请各路高手回答,就算只答对一个,我就会给您一个的分!