Exercise 2.5
(a)
'a' 字符型字面值char
L'a' 宽字符型字面值wchar_t
"a" 字符串字面值
L"a" 宽字符串字面值
(b)
10 整型字面值int
10u 无符号型字面值unsigned
10L 长整型字面值long
10ul 长整型无符号字面值unsigned long
012 八进制字面值
0xC 十六进制字面值
(c)
3.14 双精度浮点型double
3.14f 单精度浮点型float
3.14L 扩展精度浮点型long float
(d)
10 整型字面值int
10u 无符号型字面值unsigned int
10. 浮点型字面值double
10e-2 双精度浮点型double
Exercise 2.6
int month = 9, day = 7;
int month = 09, day = 07;
The first line represents the decimal integer literal value
. The second line represents the octal integer literal value, where 9 is out of the octal range and the compiler reports an error.
Exercise 2.7
(a).
\F145 e
\012 换行符
Who goes with Fergus?\n
字符串字面值const char*
(b).
3.14e1L
31.4
双精度浮点型double
(c).
1024f 出错改为1024.f
单精度浮点型float
(d).
3.14L
long double
Exercise 2.8
#include<iostream>
int main()
{
std::cout << "2\x4d\n";
std::cout << "2\t\x4d\n";
}