Home > Back-end >  For help, why when I was in VS debug to the destructor to p=p -> next trigger breakpoints, sudden
For help, why when I was in VS debug to the destructor to p=p -> next trigger breakpoints, sudden

Time:11-18


# include
using namespace std;
Struct LinkList {
int data;
LinkList * next;
};
The class LinkListClass {
LinkList * head;
Public:

LinkListClass ();
~ LinkListClass ();
Void CreateList (int d);
Friend int count (LinkListClass a, LinkListClass b);
};
LinkListClass: : LinkListClass () {
The head=new LinkList ();
The head -> next=NULL;
}
LinkListClass: : ~ LinkListClass () {
Pre LinkList *, * p;
The pre=head;
P=pre -> next;
While (p) {
Delete the pre.
The pre=p;
p=p->next;
}
Delete the pre.
}
Void LinkListClass: : CreateList (int) d {
LinkList * s;
int i,n;
Cin> n.
The head -> next=NULL;
While (d> 0) {
int a;
A=n % 10;
S=new LinkList ();
S -> data=https://bbs.csdn.net/topics/a;
S -> next=head -> next;
The head -> next=s;
N=n/10;
D -;
}
}
Int count (LinkListClass a, LinkListClass b) {
LinkList * s * r;
int num=0;
S=a.h ead -> next;
R=b.h ead -> next;
While (s!=NULL & r!=NULL) {
If (s -> data=https://bbs.csdn.net/topics/=r -> data) {
num++;
}
S=s -> next;
R=r -> next;
}
return num;
}
Int main () {
int n;
Cin> n.

for (int i=0; I {
LinkListClass a, b;
Int c, d;
Cin> d.
A.C reateList (d);
The biggest reateList (d);
C=count (a, b);
Cout }
return 0;
}
  • Related