from http://www.learncpp.com/cpp-tutorial/44-type-conversion-and-casting/
類型隱式轉(zhuǎn)換
類型隱式轉(zhuǎn)換的步驟如下所示:
Long double (highest)
Double
Float
Unsigned long int
Long int
Unsigned int
Int (lowest)
最底層是int而不是short或是char,是因?yàn)閏har和short在求值時(shí)會(huì)被擴(kuò)展為int。
隱式轉(zhuǎn)換會(huì)出現(xiàn)一些有趣的問題,如5u - 10。也許你會(huì)認(rèn)為結(jié)果是-5.但是10為int型,發(fā)生隱式轉(zhuǎn)換成unsigned int型,因此最后結(jié)果為unsigned int型,2^32 - 5。又如float fValue = 10/4;