c++标准库有很多参考资料,包括无价的ISO标准、MSDN、IBM、cppreference和cplusplus。就我个人而言,在编写c++时,我需要一个具有快速随机访问、短加载时间和使用示例的参考,而我发现cplusplus.com非常有用。然而,我经常在SO网站上听到关于该网站的负面意见,所以我想具体说明:
cplusplus.com给出的错误、误解或坏建议是什么?使用它来做编码决策的风险是什么?
我希望能够用准确的标准引用来回答关于SO的问题,因此我想发布立即可用的链接,如果不是因为这个问题,cplusplus.com将是我选择的网站。
我要提出一个略微相反的观点。在cplusplus.com上有很多好的信息。把它挑到死,是的,当然它有它的问题,但哪个网站没有呢?当然不是这个网站。住在玻璃房子里的人不应该扔石头。这里也有很多错误信息。有些公认的答案是完全错误的,有些被否决的答案(有些是否定的!)是完全正确的。
One issue with cplusplus.com is is that it is a closed site; the same goes for most the other reference sites mentioned. This goes against the grain of a community-developed site such as Stack Overflow. Acquiring the ability to make trusted edits doesn't take all that long, and even the newest of newbies can easily make suggestions for improvement. Compare that to cplusplus.com. You are a perpetual newbie if you aren't on their staff. Even if you are a key member of WG21, you have to go through their email report mechanism if you see a bug somewhere in that site. Anathema!
一个解决方案是我们在这个网站上开发自己的c++参考。这需要相当多的工作。我们必须小心不要太迂腐/太专业;很明显,cplusplus.com至少雇佣了一些技术编辑,使学究们远离困境。我们必须让信息井然有序;这里的常见问题没有很好的组织。我们还必须非常小心,不要直接从标准中喷出太多;这是非法的。
我要提出一个略微相反的观点。在cplusplus.com上有很多好的信息。把它挑到死,是的,当然它有它的问题,但哪个网站没有呢?当然不是这个网站。住在玻璃房子里的人不应该扔石头。这里也有很多错误信息。有些公认的答案是完全错误的,有些被否决的答案(有些是否定的!)是完全正确的。
One issue with cplusplus.com is is that it is a closed site; the same goes for most the other reference sites mentioned. This goes against the grain of a community-developed site such as Stack Overflow. Acquiring the ability to make trusted edits doesn't take all that long, and even the newest of newbies can easily make suggestions for improvement. Compare that to cplusplus.com. You are a perpetual newbie if you aren't on their staff. Even if you are a key member of WG21, you have to go through their email report mechanism if you see a bug somewhere in that site. Anathema!
一个解决方案是我们在这个网站上开发自己的c++参考。这需要相当多的工作。我们必须小心不要太迂腐/太专业;很明显,cplusplus.com至少雇佣了一些技术编辑,使学究们远离困境。我们必须让信息井然有序;这里的常见问题没有很好的组织。我们还必须非常小心,不要直接从标准中喷出太多;这是非法的。
cplusplus.com提供的文档通常是不正确或不完整的。
一旦这样的例子是,在cplusplus.com上的atoi文档。
atoi
在Return部分中,如果在使用函数时不能执行转换,则没有提到返回值为0。
返回节声明“…如果转换后的值超出了int可表示值的范围,则会导致未定义的行为。”
这是正确的,根据标准“如果字符串的数值不能用int表示,那么行为是未定义的”。
然而,由于没有提到0作为返回值,因此该部分不是满的,这可能会产生误导。短语“…”不执行任何转换并返回零。”在描述段之前已经满足,但在Return部分中有它是必要的。
在cplusplus.com上给出的许多样例源代码是不正确的。
许多新人在参考这些参考资料的时候都犯了严重的错误。
举个例子:
编辑:我之前引用的例子是不正确的。