程序写地就有错。

来源: 不知道我是谁 2008-12-22 15:23:38 [] [博客] [旧帖] [给我悄悄话] 本文已被阅读: 0 次 (301 bytes)
width明明是std::string,给int value,所以是不可预知的。

第一段程序,编译器没有做 type check,你得到结果“02“ 是幸运,什么结果都可能。
第二段程序,编译器做了type check - compiling error.

至于为什么不做type check,同std有关,请参考operator=的definition.

std,用了太多的template.

所有跟帖: 

agree -金枪布道- 给 金枪布道 发送悄悄话 金枪布道 的博客首页 (0 bytes) () 12/22/2008 postreply 15:24:38

所以学语言应该从C++, Pascal开始 -Fagger- 给 Fagger 发送悄悄话 Fagger 的博客首页 (130 bytes) () 12/22/2008 postreply 15:39:23

错!学语言应该从C#、Java开始 -金枪布道- 给 金枪布道 发送悄悄话 金枪布道 的博客首页 (96 bytes) () 12/22/2008 postreply 15:43:50

俺第一本编程教材书就是谭浩强的《Basic语言》...haha... -Fagger- 给 Fagger 发送悄悄话 Fagger 的博客首页 (0 bytes) () 12/22/2008 postreply 15:46:07

据说他老爷子也与时俱进出了《Java语言》和《C#语言》了 -金枪布道- 给 金枪布道 发送悄悄话 金枪布道 的博客首页 (0 bytes) () 12/22/2008 postreply 15:52:30

说的很对,这就是关键所在。 -tagheur- 给 tagheur 发送悄悄话 tagheur 的博客首页 (92 bytes) () 12/22/2008 postreply 15:33:51

Don't take anything granted, especially gcc shit -金枪布道- 给 金枪布道 发送悄悄话 金枪布道 的博客首页 (0 bytes) () 12/22/2008 postreply 15:37:46

请您先登陆,再发跟帖!

发现Adblock插件

如要继续浏览
请支持本站 请务必在本站关闭/移除任何Adblock

关闭Adblock后 请点击

请参考如何关闭Adblock/Adblock plus

安装Adblock plus用户请点击浏览器图标
选择“Disable on www.wenxuecity.com”

安装Adblock用户请点击图标
选择“don't run on pages on this domain”