#include <iostream> #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ TypeName(const TypeName&); \ TypeName& operator=(const TypeName&) typedef void (*CALLBACK)(const char*); class CBase { public: CBase() {} ~CBase() {} void Show(const char* str) { std::cout << str << std::endl; } // 在class裡要用宣告成static static void ShowCallBack(const char* str) { std::cout << str << std::endl; } private: DISALLOW_COPY_AND_ASSIGN(CBase); }; void TestCallBack(CALLBACK callback) { callback("CallBack!!!"); } int main() { CBase* want_to_callback = new CBase; TestCallBack(CBase::ShowCallBack); delete want_to_callback; return 0; }
4 年前
0 意見:
張貼留言