按如下方法构造stray pointer,编译时RP比较高计算机没有抽住,但是一个pLong的值出现了问题...
输入:
typedef unsigned short int USHORT;
#include
int main()
{
USHORT *pInt =new USHORT;
*pInt=7;
std::cout<<"*pInt:"<<*pInt<delete pInt;
long *pInt = new long;
*pLong=80000;
std::cout <<"*pLong:"<<*pLong<
*pInt=12;//trouble maker
std::cout<<"*pInt:"<<*pInt <std::Cout<<"*pLong:"<<*pLong<delete pLong;
delete pInt;
return 0
}
输出:
*pInt=7
*pLong=80000
*pInt=12
*pLong=76520
整个程序中我没有改变pLong..为什么值却发生了改变
ps:不要尝试运行这个程序...除非信任您的RP= =