我在代码中收到一条错误消息,内容为
Error C4703 potentially uninitialized local pointer variable 'x' used Project1
Error C4703 potentially uninitialized local pointer variable 'y' used Project1
,我不确定为什么。我一直在研究,并且可以找到解决此问题的正确方法。这是我的Linklist.cpp文件
如果您还想要链表文件的其余部分,那么这里是一个链接,我将其粘贴到其中 https://repl.it/repls/MushyMonthlySpyware
LinkedList::ErrorCode LinkedList::getListElement(int posStart, int posEnd, ListElement rv[]) const {
int size = getListSize();
if (posStart < 0 || posStart >= size) {
return ILLEGAL_LIST_POSITION;
}
if (posEnd < 0 || posEnd >= size) {
return ILLEGAL_LIST_POSITION;
}
if (posEnd < posStart) {
return ILLEGAL_LIST_POSITION;
}
int index = 0;
Node *x, *y;
Node *a = first;
int count = 0;
while (a != NULL) {
if (posStart == count) {
x = a;
}
if (posEnd == count) {
y = a;
}
a = a->next;
count++;
}
a = x;
while (a != y->next) {
rv[index++] = a->data;
a = a->next;
}
return NO_ERROR;
}