第一段程序,编译器没有做 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- ♂ (130 bytes) () 12/22/2008 postreply 15:39:23
• 错!学语言应该从C#、Java开始 -金枪布道- ♂ (96 bytes) () 12/22/2008 postreply 15:43:50
• 俺第一本编程教材书就是谭浩强的《Basic语言》...haha... -Fagger- ♂ (0 bytes) () 12/22/2008 postreply 15:46:07
• 据说他老爷子也与时俱进出了《Java语言》和《C#语言》了 -金枪布道- ♂ (0 bytes) () 12/22/2008 postreply 15:52:30
• 说的很对,这就是关键所在。 -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