关于迷途指针
程序代码:
typedef unsigned short int USHORT; #include <iostream.h> int main() { USHORT *pInt = new USHORT; *pInt=10; cout<<pInt<<endl; cout<<"*pInt: "<<*pInt<<endl; delete pInt; //pInt为一迷途指针! pInt=0; long *pLong = new long; cout<<pInt<<endl; cout<<pLong<<endl; *pLong=90000; cout<<"*pLong: "<<*pLong<<endl; *pInt=20; //再次使用pInt! cout<<"*pInt: "<<*pInt<<endl; cout<<"*pLong: "<<*pLong<<endl; delete pLong; returnpInt=0;设置空指针的作用是为了让以后程序崩溃的时候可预料么??还有就是
cout<<"*pInt: "<<*pInt<<endl;
cout<<"*pLong: "<<*pLong<<endl;
这两天语句的输出结果很多资料说是 *pInt:20, *pLong:65556,为什么我压根就运行不出来呢
[ 本帖最后由 gao_guai 于 2012-7-10 10:44 编辑 ]