|
the first file:
class IntNode{
public:
int onum;
char oname[10];
int oscore;
IntNode *next;
IntNode(int num,char name[10],int score,IntNode *ptr = 0){
int i=0;
onum = num;
for (i=0;i<10;i++)
oname = name;
oscore = score;
next = ptr;
}
};
class IntSLList{
public:
IntSLList(){
head = tail = 0;
}
~IntSLList();
int isempty(){
return head == 0;
}
void addToData(int,char,int);
void searchToData(int);
void deleteNode(int);
void insertToData(int,char,int);
void printToData();
private:
IntNode *head,*tail;
};
the second file:
#include <iostream>
#include "intSLList.h"
using namespace std;
IntSLList::~IntSLList(){
for(IntNode *p;!isempty();){
p = head -> next;
delete head;
head = p;
}
}
void IntSLList::addToData(int num,char name[10],int score)
{
if (tail != 0){
tail -> next = new IntNode(num,name,score);
tail = tail -> next;
}
else{
head = tail = new IntNode(num,name,score);
}
}
void IntSLList::deleteNode(int num){
if (head != 0){
if (head == tail && el == head->info){
delete head;
head = tail = 0;
}
else if (num == head -> onum){
IntNode *tmp = head -> next;
head = head -> next;
delete tmp;
}
else{
IntNode *pred,*tmp;
for (pred = head;tmp = head->next; tmp != 0,&&(tmp->onum == num);
pred = pred -> next,tmp = tmp -> next){
if (tmp != 0)
pred -> next = tmp -> next;
if (tmp == tail)
tail = pred;
delete tmp;
}
}
}
}
}
void IntSLList::searchToData(int num)
{
while(1){
if (num == head -> onum){
printf("\n");
printf("%d\n",head -> onum);
printf("%s\n",head -> name);
printf("%d\n",head -> score);
break;
}
else{
head = head -> next;
}
}
}
void IntSLList::insertToData(int num,char name[10],int score)
{
if (tail != 0){
tail -> next = new IntNode(num,name,score);
tail = tail -> next;
}
else{
head = tail = new IntNode(num,name,score);
}
}
void IntSLList::printToData()
{
while(head != tail){
printf("\n");
printf("%d\n",head -> onum);
printf("%s\n",head -> name);
printf("%d\n",head -> score);
}
}
the third file:
#include <iostream>
#include "intSLList.h"
using namespace std;
void printmenu()
{
printf("\n(1).Input your data.");
printf("\n(2).Print your data.");
printf("\n(3).Delete yout data.");
printf("\n(4).Insert yout data.");
printf("\n(5).Search your data.");
printf("\n(0).Exit.");
printf("\nInput your select num:");
}
int main()
{
IntNode *New;
int switchnum;
int Nnum;
char Nname[10];
int Nscore;
printmenu();
scanf("%d",&switchnum);
while(1){
switch(switchnum){
case 1:printf("\nInput your num:");
scanf("%d",&Nnum);
printf("\nInput your name:");
scanf("%s",Nname);
printf("\nInput your score:");
scanf("%d",&Nscore);
New -> addToData(Nnum,Nname,Nscore);
break;
case 2:New -> printToData();
break;
case 3:printf("\nInput you should del your num:");
scanf("%d",&Nnum);
New -> deleteNode(Nnum);
break;
case 4:printf("\nInput your num:");
scanf("%d",&Nnum);
printf("\nInput your name:");
scanf("%s",Nname);
printf("\nInput your score:");
scanf("%d",&Nscore);
New -> insertToData(Nnum,Nname,Nscore);
break;
case 5:printf("\nInput you search num:");
scanf("%d",&Nnum);
New -> searchToData(Nnum);
break;
case 0:exit(0);
break;
}
}
}
the result view:
liaobiao.cpp: In function `int main()':
liaobiao.cpp:35: no matching function for call to `IntNode::addToData(int&,
char[10], int&)'
liaobiao.cpp:37: no matching function for call to `IntNode::printToData()'
liaobiao.cpp:41: no matching function for call to `IntNode::deleteNode(int&)'
liaobiao.cpp:49: no matching function for call to `IntNode::insertToData(int&,
char[10], int&)'
liaobiao.cpp:53: no matching function for call to `IntNode::searchToData(int&)'
why????? :-( :-( :-( :-( :-( |
|