我是这样写的:
.h:class CStaticTest{
public:
 static int nUser;
 static int GetUser();
 static void SetUser(int nNewUser);
};extern "C" __declspec(dllexport) int GetU();.cpp:static int GetUser()
{
 return CStaticTest::nUser;
}static void SetUser(int nNewUser)
{
 CStaticTest::nUser = nNewUser;
}extern "C" __declspec(dllexport) int GetU()
{
 int n = CStaticTest::GetUser();
 return n;
}编译无法通过,是GetU函数里调用了GetUser的缘故。

解决方案 »

  1.   

    GetUser定义不对
    static int GetUser()
    {
     return CStaticTest::nUser;
    }
    改为
    int CStaticTest::GetUser()
    {
     return CStaticTest::nUser;
    }
      

  2.   

    如楼上所说,但你还得在cpp的前面加上
    int CStaticTest::nPass;
    int CStaticTest::nUser;
    否则还是会报错的。
      

  3.   

    我通AFX_EXT_CLASS导出含有static成员的类时,在使用导出类时链接不上static成员
    StdAfx.obj : error LNK2001: unresolved external symbol "protected: static int YfMenu::xp_draw_3D_bitmaps" (?xp_draw_3D_bitmaps@YfMenu@@1HA)