※ 引述《adrianshum.bbs@ptt.cc (Alien)》之銘言:
> btw, 我是覺得有分別
> 比如用回常用的例子, str[0]='x';
> 第一個寫法會 pass compilation, 只是在 runtime 可能會出問題
> (Stroustrup 的 The C++ Programming Lang 說是 behaviour undefined)
> 後者則該不能通過 compilation
> Alien
Alien 說的好像比較正確。
我在想正確的說法是不是應該說成:
const char * str = "string";
才是正確的寫法,而
char * str = "string"';
則是邏輯錯誤的寫法,是 C++ 高手應該避免的,因為容易造成行為未定義。
--
┌─────────◆女 朋 友 練 英 文◆─────────┐
│http://home.kimo.com.tw/kenidensency/english/english.html│
└───────────《From:火星》───────────┘