我接过好几次电话面试了。最烦人的一个问题(还老问)就是,how do you scale your C/C++ skill if the rate is from 0 to 10? 我TM一开始还比较谦虚,支吾了一会儿,就说大概6到7吧(毕竟C++里很多猫腻我确实不大了解)。然后对面就是一阵难堪的沉默,然后就说"I will contact you later". 我TM现在学乖了,问我rate, 我毫不犹豫地说8-9。谁TM谦虚谁就是孙子啊!
看了一下,大概是
C++的内存最小单元为byte,但是byte中存bit的数目是implementation-defined.
The sizeof operator yields the number of bytes in the object representation of its operand.
sizeof(char), sizeof(signed char) and sizeof(unsigned char) are 1; the
result of sizeof applied to any other fundamental type is implementation-defined.
* The C++ language gives the programmer the impression that memory is laid out as a sequence of something C++ calls "bytes."
* Each of these things that the C++ language calls a byte has at least 8 bits, but might have more than 8 bits.
* The C++ language guarantees that a char* (char pointers) can address individual bytes.
* The C++ language guarantees there are no bits between two bytes. This means every bit in memory is part of a byte. If you grind your way through memory via a char*, you will be able to see every bit.
* The C++ language guarantees there are no bits that are part of two distinct bytes. This means a change to one byte will never cause a change to a different byte.
* The C++ language gives you a way to find out how many bits are in a byte in your particular implementation: include the header <climits>, then the actual number of bits per byte will be given by the CHAR_BIT macro.