//---------ComOpre.h
class ComOpre
{
public:
HANDLE hd_com1,hd_com2; BOOL opencom(int port);
}//---------ComOpre.cpp
#include "stdafx.h"
#include "ComOpre.h"
BOOL ComOpre::opencom(int port)
{
return ;
}编译
--------------------Configuration: 008 - Win32 Debug--------------------
Compiling...
ComOpre.cpp
D:\XJ_Work_Station\test\1127\008\ComOpre.cpp(5) : error C2143: syntax error : missing ';' before 'tag::id'
D:\XJ_Work_Station\test\1127\008\ComOpre.cpp(5) : error C2377: 'BOOL' : redefinition; typedef cannot be overloaded with any other symbol
        d:\program files\microsoft visual studio\vc98\include\windef.h(142) : see declaration of 'BOOL'
D:\XJ_Work_Station\test\1127\008\ComOpre.cpp(5) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.
Creating browse info file...
BSCMAKE: error BK1506 : cannot open file '.\Debug\ComOpre.sbr': No such file or directory
执行 bscmake.exe 时出错.008.exe - 1 error(s), 0 warning(s)

解决方案 »

  1.   

    还有,如果有两个*.cpp引用一个*.h的文件,这个*.h文件要加什么东西吗,怎么加
      

  2.   

    class ComOpre
    {
    public:
    HANDLE hd_com1,hd_com2; BOOL opencom(int port);
    };          //加分号
      

  3.   

    class ComOpre
    {
    public:
    HANDLE hd_com1,hd_com2; BOOL opencom(int port);
    }---->这地方加一个冒号
    BOOL ComOpre::opencom(int port)
    {
    return ; ----->明明是返回一个BOOL值,你却不返回值
    }重新编译一次看看...
      

  4.   

    class ComOpre
    {
    public:
    HANDLE hd_com1,hd_com2; BOOL opencom(int port);
    }---->这地方加一个分号
      

  5.   

    多个cpp包含h文件,要防止头文件重复包含
    #ifndef _xxx
    #define xxx
    #include "xxx.h"
    #endif