題目中的問題。 我嘗試這樣做:我應該包含什麼來拋出bad_function_call異常?
throw new std::bad_function_call("!");
得到了一個錯誤:
error C2039: 'bad_function_call' : is not a member of 'std'
error C2061: syntax error : identifier 'bad_function_call'
題目中的問題。 我嘗試這樣做:我應該包含什麼來拋出bad_function_call異常?
throw new std::bad_function_call("!");
得到了一個錯誤:
error C2039: 'bad_function_call' : is not a member of 'std'
error C2061: syntax error : identifier 'bad_function_call'
This is new in C++11, and comes from the header <functional>
。包括這一點,並祈禱你有一個足夠新的編譯器。
順便說一下,你不應該動態分配異常。它是:
內存通常用於存儲直接拋出的異常對象,因此可以使用它。只寫:
throw std::bad_function_call("!");
這是一種解脫!是否_whistles_是你的貓;) –
@thokra有一隻貓在聊天中爭論這件事! –
-1:什麼阻止你簡單地谷歌搜索和從文檔中找出? –
[Documentation](http://en.cppreference.com/w/cpp/utility/functional/bad_function_call)。花了我3秒鐘找到答案。 –
對不起,只看cplusplus.com =(會注意到 – user2706838