我编写了代码来创建动态创建对象的链接列表:
#include <iostream>
using namespace std;
struct X {
int i;
X* x;
};
void birth(X* head, int quant){
X* x = head;
for(int i=0;i<quant-1;i++){
x->i = i+1;
x->x = new X;
x = x->x;
}
x->i = quant;
x->x = 0;
}
void kill(X* x){
X* next;
while(1==1){
cout << x->i << endl;
cout << (long)x << endl;
next = x->x;
delete x;
if(next == 0){
break;
} else {
x = next;
}
}
}
int main(){
cout …Run Code Online (Sandbox Code Playgroud)