class Node{
public:
int data;
Node* next;
void ptrintNode(){
cout << data << endl;
}
};
class singleList{
public:
singleList();
~singleList();
bool Find(int i,int *x);
bool Insert(int i,int *x);
bool Delete(int i);
void Trverse();
private:
Node *first;//创建头指针
int n;
};
singleList::singleList(){
first = new Node;
first->data = 0;
first->next = NULL;
n = 0;
}
singleList::~singleList(){
Node *p;
while (first){
p = first->next;
delete first;
first = p;
}
}
bool singleList::Find(int i, int *x){
if (i<0||i>n-1) return false;
Node *p = first;
for (int j=0; j<i; j++){
p = p->next;
}
*x = p->data;
return true;
}
我想问一下第11行和第十二行两行是什么意思?为啥它们不像下面的函数一样有表明返回类型(如bool)?以及在下面这两个所定义的函数是干什么用的?
singleList();
~singleList();