现有一个test1.h,test1.cpp,test2.h,test2.cpp,main.cpp
接口函数在main.cpp中
main.cpp中要调用到test1.h,test2.h中定义的东西
请问vc编译器是怎么去编译的呀?
我怎么样才能够让他们被编译通过?
先谢过!

解决方案 »

  1.   

    //main.cpp
    #include "test1.h"
    #include "test2.h"
      

  2.   

    在main.cpp包含进需要的头文件。
    注意你的test1.h,test2.h文件是否在相同目录下
      

  3.   

    那我就是这样做的
    不过我就把那几个文件都和到工程里面来了
    而后我编译的时候
    出错说 test1.cpp 文件没有结束
    (c1010号错误:unexpected end of file while looking for precompiled header directive)
    还有就是这样#include又是怎么样去避免把一个头文件#include两次这样的情况的呢?
      

  4.   

    to: xiaobei525(汤姆) 
    预编译头又是怎么去注意的呢?
    我是新手
    能否指点一下? 谢谢
      

  5.   

    一个头文件#include n次 有问题吗
      为什么要避免
      

  6.   

    在每个h文件include "stdafx.h"在test.h包含
    #ifndef  test_h
    #define  test_h.....你的定义
    #endif
    在test2.h包含
    #ifndef  test_h
    #define  test_h.....你的定义
    #endif
      

  7.   

    sorry,在test2.h中改一下
    #ifndef  test2_h
    #define  test2_h.....你的定义
    #endif
      

  8.   

    sstower() ( ) 说得很清楚了,我就不说了!
      

  9.   

    #include "stdafx.h"
    "stdafx.h"有什么作用?
    std是标准名字空间吗?afx好象一般的mfc函数头都有。
    我昨天在程序里面加 #include <Winsock2.h>
    以后就出现了好多vc标准库里面有命名冲突
    而后我就去掉了 #include <Winsock2.h>
    添加了#pragma comment(lib, "Ws2_32")库就编译通过了
    而后我就在想问题所在
    第一我没有明明跟库里面冲突
    那会不会已经在别的文件里面#include <Winsock2.h>
    而后就冲突了?
    谢谢