所以,我定義爲一個函數指針:C++:我用什麼類型來定義這張地圖?
unsigned static int (*current_hash_function)(unsigned int);
而我試圖讓地圖指針的函數名:
typedef std::map<fptr_t, std::string> function_map_t;
但我得到這個錯誤:
src/main.h:24: error: ISO C++ forbids declaration of
‘fptr_t’
with no type
其他代碼:
main.h:
typedef (*fptr_t)(unsigned int*);
typedef std::map<fptr_t, std::string> function_map_t;
function_map_t fmap;
不是你的問題的答案,但是...如果你的編譯器支持一些C++ 0x功能,我建議使用std :: function通過typedefs函數指針。他們會更容易閱讀,並且更加靈活。 – luke 2011-05-10 19:54:06