|

楼主 |
发表于 2003-10-23 16:54:39
|
显示全部楼层
谢谢libinary的细心论述,
stack对这个问题的理解好象和你不同,
http://www.linuxquestions.org/qu ... amp;threadid=106915
quote: ui is of type int and when you call cout<<ui<<endl; you are asking for the address of the integer pointer. Now since you have assigned the pointer to null it will display 00000 since that is the address you assigned to ui.
uc is of type char and when you call cout<<uc<<endl; you are asking for the value of the string, now we run into a problem... so we are actually asking for the value stored by the pointer which does not exist so we crash"
我想他认为当程序运行至cout<<ui<<endl; 时,需要访问ui的地址,因为我把NULL赋值给了int* ui, 所以将输出00000;
当程序运行至cout<<ui<<endl; 时,需要访问由指针来贮存的string的值,但实际上它是不存在的。
|
|