天天看点

【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之间的差别问题。

继续阅读