红移中的宇宙 2022-06-13 14:02 采纳率: 100%
浏览 31
已结题

指针值的四个状态是什么意思?

拿《C++ primer》自学C++,书上说指针的值有四种可能状态。其中一个说“指向紧邻对象所占空间的下一个位置”,这是什么意思?
最后一种是“无效指针”,什么时候才会出现无效指针?请大家赐教。

  • 写回答

2条回答 默认 最新

  • 假装不困 2022-06-13 14:33
    关注

    无效指针一般是释放对应的对象,但是你没把指针指向 nullptr,图中的 tmp 已经被释放了,tmp 本身还是有值,指向的内容被释放了

    img

    指向紧邻对象所占空间的下一个位置:你继续往后看,看到容器的相关的章节,end 指向的位置就是紧邻对象的下一个位置

    Return iterator to end
    Returns an iterator referring to the past-the-end element in the map container.
    The past-the-end element is the theoretical element that would follow the last element in the map container. It does not point to any element, and thus shall not be dereferenced.
    Because the ranges used by functions of the standard library do not include the element pointed by their closing iterator, this function is often used in combination with map::begin to specify a range including all the elements in the container.
    If the container is empty, this function returns the same as map::begin.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 6月23日
  • 已采纳回答 6月15日
  • 创建了问题 6月13日

悬赏问题

  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 基于52单片机的酒精浓度检测系统加继电器和sim800
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答