Beginning Visual c++ 2010一书中第55页
书上讲到In spite of this, type char and type signed char are different types, so you should not make the mistake of assuming they are the same.
明确说出char 和 signed char不是同一类型。
但是,本段开头却说This is because these types are assumed to have the default type modifi er signed .即char 本来就认为是省略了signed 。
到底如何理解。。。
[解决办法]
This is because these types are assumed to have the default type modifier signed.
...
In spite of this, type char and type signed char are different types, so you should not make the mistake of assuming they are the same.
先从字面上来看:“这是因为。。。尽管如此。。。”,所以应该是开头说一般情况,然后一个转折讲述例外。
再抠抠字眼“these types”是哪些类型,真的包含了char么?
最后从C语言来讲(以下陈述不一定准确,请自行搜索求证),根据C语言“标准”,对于char、short、int和long这四种类型,如果前面没有modifier,那么默认是signed,否则就以modifier为准。但是依稀记得,这其实是依赖“实现”的,有的编译器是把char当成unsigned char来处理的,char是个“例外”,不能做“一般假定”。
再最后,建议LZ可以看看C语言之外的一些书,比如《计算机科学:从程序员的视角》,因为C是比较接近底层的语言,看看课外书可以补上课内无法完全理解的东西。到那时候,也许LZ根本就不会纠结于signed和unsigned之间了,如何取用也是随意自如。
Beginning Visual c++ 2010一书中第55页解决方案
Beginning Visual c++ 2010一书中第55页书上讲到In spite of this, type char and type signed char are d
