简体   繁体   English

Visual Studio上调用堆栈的C ++ Getter和Setters替代方法

[英]C++ Getters and Setters alternatives for Call Stack on Visual Studio

I'd like to know if there is a way to inspect the data os this piece of code with a breakpoint in Visual Studio: 我想知道是否有一种方法可以在Visual Studio中使用断点检查这段代码中的数据:

someClass.someVar = 12;

In the same way i would with this one: 用同样的方式,我会这样:

someClass.SetSomeVar(12);

There is a way to know the variable's data without making getters and setters ??? 有一种无需创建getter和setter即可知道变量数据的方法?

There is a concept called data breakpoint that may help you achieve debugging as you stated, without necessarily modifying your code. 有一个称为数据断点的概念,它可以帮助您按照说明进行调试,而不必修改代码。 You may also want to look into this post on data breakpoints. 您可能还想看看这篇关于数据断点的文章。

However if the type T that someVar belongs to is not primitive, the simplest way to achieve the desired result is overloading operator= of that type, and set a simple breakpoint in the scope of that overloaded method. 但是,如果someVar所属的类型T不是原始类型,则实现所需结果的最简单方法是重载该类型的operator =,并在该重载方法的范围内设置一个简单的断点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM