1. 程式人生 > >C++Static 靜態函式呼叫非靜態函式

C++Static 靜態函式呼叫非靜態函式

 test.h
class test :
{
public:
    test(void);
    ~test(void);


public:
    //你的其他函式
    ...
    ....
protected:

    //你的其他函式
    ...
    ...
    static void CALLBACK TimeProcFu(HWND hwnd,UINT message,UINT idTime,DWORD dwTime);

    void aa();
private:
    static test* m_staticSelf; 
};
test.cpp

test* test:
:m_staticSelf; test::test(void) { //建構函式 m_staticSelf = this; } test::~test(void) { } void CALLBACK test::TimeProcFu( HWND hwnd,UINT message,UINT idTime,DWORD dwTime ) { m_staticSelf->aa(); } void test::aa() { //你的執行程式碼 }