自从迁移到 Xcode 3 到 4.3 后,在调试器中我一直无法查看嵌套模板类(如链表)中的成员变量。有人对如何查看有任何想法吗?这是一个示例,然后是我在调试器的“变量”窗口中可以看到和看不到的内容:
template<class T> class linkedList;
template<class T> class listItem;
template<class T> class listItem {
public:
T data;
listItem<T> *previous, *next;
listItem(T x):data(x), previous(0), next(0){}
};
template<class T> class linkedList{
public:
int length;
listItem<T> *first,*last;
linkedList(void): first(0), last(0), length(0) {}
~linkedList(void){Clear();}
void Append(T x);
void Clear(void){
while(length>0) DeleteLast();}
void DeleteLast(void);
};
template<class T> void linkedList<T>::Append (T x) {
listItem<T> *item = new listItem<T>(x);
if (length == 0) {first = item;}
else {
item->previous = last;
last->next = item;}
item->next = NULL;
last = item;
length++;
}//Append
template<class T> void linkedList<T>::DeleteLast (void) {
if (length > 0) {
listItem<T> *item = last;
if (length == 1) {
first = last = NULL;
length = 0;
delete item; item = NULL;
return;}
else if (length == 2) {
last = item->previous;
last->next = NULL;
first = last;}
else {
item->previous->next = NULL;
last = item->previous;}
length--;
delete item;item=NULL;
}
}//DeleteLast
int main(){
linkedList<int> theList;
theList.Append(4);
theList.Append(5);
return 0;
}
逐步浏览并在变量窗口中观察,我最终得到:
theList= (linkedList<int>)
length= (int) 2
first= (listItem*) 0x0000000100100a80
last= (listItem*) 0x0000000100100aa0
我想看到的不仅仅是项目“first”和“last”的地址,而是它们的取消引用内容,整数 4 和 5。这些信息在 Xcode 3 中可见。
有什么想法吗?