我写了一个类class mysock:public Asynsocket
           {类的申明;}
然后在类mydlg中引用class mydlg:public CDialog
          {mysock m_sock;
                 }
我在mydlg前面包括了#include"mysock.h"
                      #include"stdafx.h"
但编译时,就是说mysock error C2501: 'mysock' : missing storage-class or type specifiers我将//mysock m_sock 注销后编译正常,百思不得其解.

解决方案 »

  1.   

    是CAsyncSocket,不是Asynsocket,另外记得加上Afxsock.h
      

  2.   

    我在sdtafx.h的头文件中已经加入了#include<afxsock.h>但还是不行,我痛苦!!
      

  3.   

    #include"mysock.h"
    包在对话框的头文件中
      

  4.   

    是CAsyncSocket,不是Asynsocket,就是了
      

  5.   

    #include"mysock.h"
                          是不是
    要这样
    #include"cmysock.h"
                          
      

  6.   

    //head file mydlg.h
    //以下是class的申明
    #include"mysock.h"
    #include"stdafx.h"//在sdtafx.h的头文件中已经包含了#include<afxsock.h>
    class mydlg:Public CDialog
    {public:
       mysock m_sock;
    }
    编译后就出现如上所显示的错误,
    但是//mysock m_sock后编译正常,也就是说#incliude"mysock.h" 头文件没错下面是用到的mysock类的申明
    //head file mysock.h
    #include'stdafx.h"//在该头文件中已有#include<afxsock.h>//以下是class的申明
    class mysock:public CAsyncSocket
    {
    }
    谢谢各位能来看看,我真有点晕了!!
      

  7.   

    #include"stdafx.h"
    #include"mysock.h"
      

  8.   


    check the #ifdef XXX / #define XXX / #endif in your header file.if you have two header file with same XXX? When you copy one header to create another header file. (guess).
      

  9.   

    #include"stdafx.h"要放到最前面。
      

  10.   

    在mydDlg类的头文件
    class mysock;class mydlg:Public CDialog
    {public:
       mysock m_sock;
    }再在mydlg类的cpp文件里加上:
    #include "mysock.h"