图书馆借阅系统一个小小的问题
#include<iostream>#include<math.h>
#include<string.h>
using namespace std;
//-----retrival----------------------
class retrival
{protected:
char Title[40];
long Code;
public:
retrival(void);
retrival(char *title,long code);
long getcode()
{
return Code;
}
void show();
};
retrival::retrival(void)
{
strcpy("title"," ");
Code=0;
}
retrival::retrival(char *title,long code)
{
strcpy(Title,title);
Code=code;
}
void retrival::show()
{
cout<<"资料"<<Title<<endl;
cout<<Code<<endl;
}
//-----book----------------------
class book:public retrival
{
private:
char Author[20];
char indexcode[10];
public:
book();
book(char *author,char *title,char *index,long code);
void show();
};
book::book(char *author,char *title,char *index,long code):retrival(title,code)
{
strcpy(Author,author);
strcpy(indexcode,index);
}
void book::show()
{
cout<<"图书"<<Title<<" ";
cout<<Author<<" ";
cout<<indexcode<<" ";
cout<<Code<<" "<<endl;
}
//-----magazine----------------------
class magazine:public retrival
{
private:
int volume;
public:
magazine();
magazine(char *title,int vol,long code);
void show();
};
magazine::magazine():retrival()
{
volume=0;
}
magazine::magazine(char *title,int vol,long code):retrival(title,code)
{
volume=vol;
}
void magazine::show()
{
cout<<"杂志"<<Title<<" ";
cout<<volume<<" ";
cout<<Code<<" "<<endl;
}
//-----reader----------------------
class reader
{
private:
char Name[20];
long Code;
book *books;
int CounterB;
magazine *magazines;
int CounterM;
public:
reader()
;
reader(char *name,long code);
~reader();
void show();
void showbooks();
void showmagazines();
void addbook(book it);
void addmagazine(magazine it);
void delbook(book it);
void delmagazine(magazine it);
};
reader::reader()
{
strcpy(Name," ");
Code=0;
books=new book[5];
CounterB=0;
magazines= new magazine[10];
CounterM=0;
}
reader::reader(char *name,long code)
{
strcpy(Name,name);
Code=code;
books=new book[5];
CounterB=0;
magazines= new magazine[10];
CounterM=0;
}
reader::~reader()
{
delete books;
delete magazines;
}
void reader::show()
{
cout<<"读者";
cout<<Name;
cout<<Code<<endl;
}
void reader::showbooks()
{
if(CounterB==0)
{
cout<<"书已还清";
return;
}
for(int i=0;i<CounterB;i++)
books[i].show();
}
void reader::showmagazines()
{
if(CounterB==0)
{
cout<<"杂志已还清"<<endl;
}
for(int i=0;i<CounterB;i++)
magazines[i].show();
}
void reader::addbook(book it)
{
if(CounterB<5)
{
books[CounterB]=it;
CounterB++;
}
else
{
cout<<"你已经借满了五本书!"<<endl;
}
}
void reader::delbook(book it)
{
int i;
for(i=i=CounterB;i>0;i--)
if(books[i].getcode()==it.getcode()) break;
for(int j=i;j<CounterB;j++)
books[j]=books[j+1];
CounterB--;
}
void reader::addmagazine(magazine it)
{
if(CounterM<10)
{
magazines[CounterM]=it;
CounterM++;
}
else
{
cout<<"你已经借满了10本杂志!"<<endl;
}
}
void reader::delmagazine(magazine it)
{
int i;
for(i=CounterM;i>0;i--)
if(magazines[i].getcode==it.getcode()) break;
for(int j=i;j<CounterM;j++)
magazines[j]=magazines[j+1];
CounterM--;
}
int main()
{
book b1("lisa","计算机分析","c285/56",10014);
book b2("rose","数值计算","c285/78",10067);
magazine m1("美好时光",2,40007);
magazine m2("船舰技术",8,40025);
reader r1("王尚",30001);
reader r2("李斯",30002);
r1.show();
r2.show();
r1.addbook(b1);
r1.addbook(b2);
cout<<endl<<"读者R1的书明细"<<endl;
r1.showbooks();
r1.delbook(b1);
cout<<endl;
cout<<"after return"<<b1.getcode()<<"book:"<<endl;
r1.showbooks();
cout<<endl<<"读者R2的杂志明细"<<endl;
r2.addmagazine(m1);
r2.addmagazine(m2);
r2.delmagazine(m1);
r2.showmagazines();
return 0;
}
就红体字错了 不知道为什么 查了半天 错误是error C2446: '==' : no conversion from 'long' to 'long (__thiscall retrival::*)(void)'
哪位大神指导下