gpt4 book ai didi

c++ - 调试时将鼠标悬停在 Visual Studio 中的 operator->() 之后查看字段

转载 作者:太空狗 更新时间:2023-10-29 23:43:54 25 4
gpt4 key购买 nike

我有一个小类(class):-

class A{   public:int aField;   }

下面,在调试时,如果我将鼠标悬停在 a->aField 中的 aField 周围,Visual Studio 会很好地弹出该字段的值(就像一个小 watch ).

A* a=new A();
a->aField=1234;
//^ hover here

然后我升级了代码以覆盖 operator->:-

class APtr{ //my custom smart pointer
A* ptr;
A* operator->(){ return ptr; }
}

APtr a;
.....
a->aField=1234;
//^ hover here

没有弹出窗口了。 (a 有弹出窗口,aField 没有)
如何让可爱的弹窗再次出现?

编辑(赏金原因):“user1610015”提供了一个可行的解决方案,但我认为可能有更方便的解决方案(只有一点点帮助)。一个新的解决方案甚至可以建议我使用一些插件或其他 IDE。

编辑 2:
这是我想要的可爱弹出窗口的示例。
它不适用于 operator-> 之后的字段。

enter image description here

最佳答案

调试器无法识别运算符->,但您可以通过将鼠标悬停在智能指针变量上然后单击工具提示上的向右箭头来获取相同的信息:

enter image description here

关于c++ - 调试时将鼠标悬停在 Visual Studio 中的 operator->() 之后查看字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39339959/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com