VS 2010中观察窗口自动查看向量元素的方法
是否有任何技术可以让人们将矢量元素放入监视窗口中,并在其更改时实际看到它的更新?
这就是上下文。
vector<int> x;
x.push_back(3);
然后将x[0]放入监视窗口中,实际看到它的值。
如果无法解决该问题,最好的替代方案是什么?
Is there any technique that would let one put a vector element in a watch window, and actually see it update when it changes?
This is the context.
vector<int> x;
x.push_back(3);
Then put x[0] into the watch window and actually see its value.
Failing a solution to that issue, what is the best alternative?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将
x
添加到监视窗口。 VS 应该显示它的元素。单击左侧的加号链接可查看其各自行中的元素。单击元素的名称(即x[0]
)并将其拖到监视窗口中自己的空白行中。这应该会给你一个新的行来观察你想要的元素。确保您单击拖动的是变量名称而不是其值(拖动值将观察该值)。Add
x
to a watch window. VS should display its elements. Click on the plus link to the left to see its elements each in its own row. Click on the name of the element (i.e.x[0]
) and drag it into its own blank row in the watch window. That should give you a new row watching the element you wanted. Make sure what you click on for dragging is the variable name and not its value (dragging the value will watch the value).巴勃罗的方法仅适用于固定索引值。如果你想使用变量设置索引,请使用:
它很难看并且很难记住,但确实有效。
Pablo's method works for only fixed index values. If you want to set the index using a variable use:
It is ugly and hard to remember but does the trick.