我有一些丑陋的滞后代码,我试图理解并想要调试它们。
情况:
class A{
// some members and functions
// but no virtual ones
};
class B:public A
{
// contains virtual methods
}
class C:public B
{}
// now somewhere there is an array of pointers to A;
A* someList[FixSize];
// and another struct contains a pointer to that someList.
struct T{
A** list;
}t;
someList
的数组元素实际上是C
类型。因为 A
不包含任何虚拟方法,所以调试器只显示该列表中的 A 元素,并且不在其 TreeView 中提供子类成员。
将 list
指针转换为 C**
显然是行不通的,因为 C
对象与其 A
部分。
如果将 (C*)(t->list[0])
设置为监视,则调试器会显示正确的数据。但是以这种方式检查 50 个对象不是很方便。
有没有人知道一些聪明的方法来处理这个。
最佳答案
(C**)t->list,10
正在 Visual Studio 2010 中进行工作测试。
根据您的 struct T {} t
定义,它应该是 (C**)(t.list),10
关于c++ - visual studio 调试器 - 观察指针转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24824243/