天天看點

【C++錯誤處理】VC6中關于bool __cdecl std::isdigit(_E,const class std::locale &)' : expects 2 arguments

今天在用VC6調試一個别人寫的示例程式時,發現了這麼一個錯誤:

bool __cdecl std::isdigit(_E,const class std::locale &)' : expects 2 arguments

出錯的代碼:

1.  return std::isdigit(_expr[_pos]) != 0; 

2.          <b>bool</b> (isdigit)(_E _C, const locale&amp; _L) 

3.   

4.  while (_pos &lt; _expr.length() &amp;&amp; std::isdigit(_expr[_pos]) != 0) 

MSDN中 對isdigit的定義如下:

template&lt;class E&gt;;

    bool isdigit(E c, const locale&amp; loc) const;    

The template function returns use_facet&lt; ctype&lt;E&gt;; &gt;;(loc). is(ctype&lt;E&gt;;:: digit, c).

沒有怎麼看懂為什麼MS把這麼簡單的一個函數定義的如此複雜...

後來看一個老外的解決方法:

you are using the std template version is isdigit which apparently requires two parameters. remove the std:: namespace and the compiler will use the standard C version that only requires one parmeter.

自然就解決了VC6标準模闆和标準C之間的差别問題。

繼續閱讀