- 论坛徽章:
- 0
|
原帖由 delimy 于 2007-5-13 12:59 发表
比较想知道这个兼容在C++标准哪一节规定的
摘自The C++ Programming Language Special edition,5.2.2 String Literals):
The type of a string literal is "array of the appropriate number of const characters", so " Bohr" is of type const char[5].
...
A string literal can be assigned to a char*. This is allowed because in previous definitions of C and C++ , the type of a string literal was char*. Allowing the assignment of a string literal to a char* ensures that millions of lines of C and C++ remain valid. It is, however, an error to try to modify a string literal through such a pointer; |
|