代码改变世界

C++ pointer

  @学无止境  阅读(2)  评论(0编辑  收藏  举报
复制代码
    int* pInt = new int;
    *pInt = 5;
    cout << "---------------" << endl;
    cout << "&(*pInt)-->" << &(*pInt) << endl;
    cout << "pInt-->" << pInt << endl;
    cout << "&pInt-->" << &pInt << endl;
    delete pInt;
    cout << "---------------" << endl;
    //cout << "*pInt-->" << *pInt << endl;
    cout << "pInt-->" << pInt << endl;
    cout << "&pInt-->" << &pInt << endl;
    pInt = nullptr;
    cout << "---------------" << endl;
    //cout << "*pInt-->" << *pInt << endl;
    cout << "pInt-->" << pInt << endl;
    cout << "&pInt-->" << &pInt << endl;
复制代码

输出

---------------
&(*pInt)-->00947918
pInt-->00947918
&pInt-->0078FA4C
---------------
pInt-->00008123
&pInt-->0078FA4C
---------------
pInt-->00000000
&pInt-->0078FA4C

 

相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
点击右上角即可分享
微信分享提示