作者ric2k1 (Ric)
看板EE_DSnP
标题[情报] 期末考示范考题 (三)
时间Mon Jan 14 00:18:41 2008
(OK... 最後一题)
How many compilation error(s) is(are) there in the following code?
For the assignments on lines 11-13, if they can be compiled, please describe
how the assignments work. If they cannot be compiled, please explain why.
============================================================
1 #include <string>
2
3 using std::string;
4
5 int main()
6 {
7 char a[6] = "12345";
8 char *b = "12345";
9 string c = "12345";
10
11 a = "Hello";
12 b = "World";
13 c = "Peace";
14
15 return 0;
16 }
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 59.121.135.175
1F:→ ric2k1:这题难易度是: 中等偏难 (观念要清楚) 01/14 00:19
2F:→ ric2k1:不过其实也没那麽难, 对吧? 01/14 00:19
3F:推 louis123321:请问...老师允许我这种英文不好的人带电子字典嘛?? 01/14 00:37
4F:→ ric2k1:看不懂题目的可以举手问助教或是我... 不要客气. 01/14 00:39
5F:推 ShooterYang:为甚麽可以把"World"assign给b呢 他不是pointer吗 01/14 18:11
6F:→ ShooterYang:Pointer不是应该要存一个"位置"? 01/14 18:13
7F:推 ShooterYang:ㄜ....我来乱的 忽然发现这是一道问题 01/14 18:19
8F:→ keyboardle:其实"World"可以assign喔...错的是另一个... 01/15 18:16