主题:__int64与 operator问题
#include <iostream.h>
#include <string>
class SingleList;
class student
{
private:
__int64 num;
char sex;
char name[10];
char come_from[20];
friend class SingleList;
public:
void setsex(char s)
{
sex=s;
}
bool operator==(student& d)
{
if( sex == d.sex)
return true;
else
return false;
}
bool operator!=(student& d)
{
return sex != d.sex;
}
friend ostream & operator << (ostream & os,const student &d)
{
os<<d.num<<" "<<d.sex<<" "<<d.name<<" "<<d.come_from<<endl;
return os;
}
friend istream & operator >>(istream& is,student &d)
{
is>>d.num>>d.sex>>d.name>>d.come_from;
return is;
}
};
class Node
{
private:
student element;
Node *link;
friend class SingleList;
};
class SingleList
{
private:
Node * first;
int n;
public:
SingleList()
{
first=NULL;
n=0;
}
bool Find(int i,student & x)const
{
if (i<0 || i>n-1)
{
return false;
}
Node *p=first;
for (int j=0; j<i; j++)
p=p->link;
x=p->element;
return true;
}
bool Insert(int i, student x)
{
if (i<-1 || i>n-1)
{
return false;
}
Node * q=new Node;
q->element=x;
Node *p=first;
for (int j=0; j<i; j++)
p=p->link;
if(i>-1)
{
q->link=p->link;
p->link=q;
}
else
{
q->link=first;
first=q;
}
n++;
return true;
}
int Search(student x)const
{
Node *p=first;
for(int j=0;p && p->element != x;j++)
p=p->link;
if(p)
return j;
return -1;
}
bool Delete(int i)
{
if ( !n )
{
return false;
}
if (i<0 || i>n-1)
{
return false;
}
Node *p=first,*q=first;
for (int j=0; j<i-1; j++)
q=q->link;
if(i==0)
first=first->link;
else
{
p=q->link;
q->link=p->link;
}
delete p;
n--;
return true;
}
void Output(ostream & out)const
{
Node *p=first;
while(p)
{
out<<p->element;
p=p->link;
}
}
};
void main()
{
int N;
student d;
student td;
SingleList LA;
cin>>N;
for(int i=0;i<N;i++)
{
cin>>d;
LA.Insert(i-1,d);
}
for(int j=0;j<N;j++)
{
td.setsex('m');
LA.Delete(LA.Search(td));
}
LA.Output(cout);
}
__int64与 operator问题
怎么改啊
跪求各路大神帮帮忙
#include <string>
class SingleList;
class student
{
private:
__int64 num;
char sex;
char name[10];
char come_from[20];
friend class SingleList;
public:
void setsex(char s)
{
sex=s;
}
bool operator==(student& d)
{
if( sex == d.sex)
return true;
else
return false;
}
bool operator!=(student& d)
{
return sex != d.sex;
}
friend ostream & operator << (ostream & os,const student &d)
{
os<<d.num<<" "<<d.sex<<" "<<d.name<<" "<<d.come_from<<endl;
return os;
}
friend istream & operator >>(istream& is,student &d)
{
is>>d.num>>d.sex>>d.name>>d.come_from;
return is;
}
};
class Node
{
private:
student element;
Node *link;
friend class SingleList;
};
class SingleList
{
private:
Node * first;
int n;
public:
SingleList()
{
first=NULL;
n=0;
}
bool Find(int i,student & x)const
{
if (i<0 || i>n-1)
{
return false;
}
Node *p=first;
for (int j=0; j<i; j++)
p=p->link;
x=p->element;
return true;
}
bool Insert(int i, student x)
{
if (i<-1 || i>n-1)
{
return false;
}
Node * q=new Node;
q->element=x;
Node *p=first;
for (int j=0; j<i; j++)
p=p->link;
if(i>-1)
{
q->link=p->link;
p->link=q;
}
else
{
q->link=first;
first=q;
}
n++;
return true;
}
int Search(student x)const
{
Node *p=first;
for(int j=0;p && p->element != x;j++)
p=p->link;
if(p)
return j;
return -1;
}
bool Delete(int i)
{
if ( !n )
{
return false;
}
if (i<0 || i>n-1)
{
return false;
}
Node *p=first,*q=first;
for (int j=0; j<i-1; j++)
q=q->link;
if(i==0)
first=first->link;
else
{
p=q->link;
q->link=p->link;
}
delete p;
n--;
return true;
}
void Output(ostream & out)const
{
Node *p=first;
while(p)
{
out<<p->element;
p=p->link;
}
}
};
void main()
{
int N;
student d;
student td;
SingleList LA;
cin>>N;
for(int i=0;i<N;i++)
{
cin>>d;
LA.Insert(i-1,d);
}
for(int j=0;j<N;j++)
{
td.setsex('m');
LA.Delete(LA.Search(td));
}
LA.Output(cout);
}
__int64与 operator问题
怎么改啊
跪求各路大神帮帮忙