I don't claim to have read all your code, or even understand it if I did, but what are you trying to do here?
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
|
void initVStack(vStack* &(v)){
vRecordNode *temp = new (nothrow) vRecordNode;
vStack *topOfStack = new (nothrow) vStack;
while(topOfStack != NULL){
temp = v->topOfStack;
v->topOfStack = v->topOfStack->next;
delete temp;
delete topOfStack;
}
}
|
Doesn't it just boil down to
1 2 3
|
void initVStack(vStack* &(v)){
v->topOfStack = v->topOfStack->next;
}
|
I mean, you declare a vRecordNode pointer named
temp
and assign
v->topOfStack
to it, but almost immediately afterwards, you delete it. You don't actually use it to do anything.
As for
topOfStack
, it's a vStack pointer but all you do is make it point to a new vStack. Then you use it as the control variable for your loop, where you delete it, thereby invalidating loop conditions. In other words, you make sure the loop only runs once. And you don't do anything with the new vStack you made it point to.
As for this other function
231 232 233 234 235 236 237 238 239 240 241 242 243
|
void initAStack(aStack* &(a)){
vRecordNode *temp;
while(a->topOfStack != NULL){
temp = a->topOfStack;
a->topOfStack = a->topOfStack->next;
delete temp;
}
}
|
Again, why do you need the pointer
temp
? All you do is assign
a->topOfStack
to it and then delete it almost immediately afterwards without using it for anything.