简体   繁体   中英

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:

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 ???

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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